-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path709.py
35 lines (29 loc) · 874 Bytes
/
709.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# [ LeetCode ] 709. To Lower Case
def solution(s: str) -> str:
return s.lower()
def another_solution(s: str) -> str:
difference: int = ord("a") - ord("A")
return "".join([
chr(difference + ord(character))
if ord(character) >= ord("A") and ord(character) <= ord("Z")
else character
for character in s
])
if __name__ == "__main__":
cases: list[dict[str, dict[str] | str]] = [
{
"input": {"s": "Hello"},
"output": "hello"
},
{
"input": {"s": "here"},
"output": "here"
},
{
"input": {"s": "LOVELY"},
"output": "lovely"
}
]
for case in cases:
assert case["output"] == solution(s=case["input"]["s"])
assert case["output"] == another_solution(s=case["input"]["s"])