File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11def lower (word : str ) -> str :
2-
32 """
43 Will convert the entire string to lowecase letters
54
@@ -9,7 +8,6 @@ def lower(word: str) -> str:
98 'hellzo'
109 >>> lower("WHAT")
1110 'what'
12-
1311 >>> lower("wh[]32")
1412 'wh[]32'
1513 >>> lower("whAT")
@@ -19,9 +17,7 @@ def lower(word: str) -> str:
1917 # converting to ascii value int value and checking to see if char is a capital
2018 # letter if it is a capital letter it is getting shift by 32 which makes it a lower
2119 # case letter
22- return "" .join (
23- chr (ord (char ) + 32 ) if 65 <= ord (char ) <= 90 else char for char in word
24- )
20+ return "" .join (chr (ord (char ) + 32 ) if "A" <= char <= "Z" else char for char in word )
2521
2622
2723if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -8,17 +8,14 @@ def upper(word: str) -> str:
88 'HELLO'
99 >>> upper("WHAT")
1010 'WHAT'
11-
1211 >>> upper("wh[]32")
1312 'WH[]32'
1413 """
1514
1615 # converting to ascii value int value and checking to see if char is a lower letter
1716 # if it is a capital letter it is getting shift by 32 which makes it a capital case
1817 # letter
19- return "" .join (
20- chr (ord (char ) - 32 ) if 97 <= ord (char ) <= 122 else char for char in word
21- )
18+ return "" .join (chr (ord (char ) - 32 ) if "a" <= char <= "z" else char for char in word )
2219
2320
2421if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments