Skip to content

Commit 1926289

Browse files
authored
Create to-lower-case.py
1 parent 58ffc83 commit 1926289

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Python/to-lower-case.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# Implement function ToLowerCase() that has a string parameter str,
5+
# and returns the same string in lowercase.
6+
7+
class Solution(object):
8+
def toLowerCase(self, str):
9+
"""
10+
:type str: str
11+
:rtype: str
12+
"""
13+
return "".join([chr(ord('a')+ord(c)-ord('A'))
14+
if 'A' <= c <= 'Z' else c for c in str])

0 commit comments

Comments
 (0)