File tree 2 files changed +2
-9
lines changed
2 files changed +2
-9
lines changed Original file line number Diff line number Diff line change 1
1
def lower (word : str ) -> str :
2
-
3
2
"""
4
3
Will convert the entire string to lowecase letters
5
4
@@ -9,7 +8,6 @@ def lower(word: str) -> str:
9
8
'hellzo'
10
9
>>> lower("WHAT")
11
10
'what'
12
-
13
11
>>> lower("wh[]32")
14
12
'wh[]32'
15
13
>>> lower("whAT")
@@ -19,9 +17,7 @@ def lower(word: str) -> str:
19
17
# converting to ascii value int value and checking to see if char is a capital
20
18
# letter if it is a capital letter it is getting shift by 32 which makes it a lower
21
19
# 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 )
25
21
26
22
27
23
if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -8,17 +8,14 @@ def upper(word: str) -> str:
8
8
'HELLO'
9
9
>>> upper("WHAT")
10
10
'WHAT'
11
-
12
11
>>> upper("wh[]32")
13
12
'WH[]32'
14
13
"""
15
14
16
15
# converting to ascii value int value and checking to see if char is a lower letter
17
16
# if it is a capital letter it is getting shift by 32 which makes it a capital case
18
17
# 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 )
22
19
23
20
24
21
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments