Skip to content

Commit f968dda

Browse files
its-100rabhcclauss
andauthored
Updated Comments on upper.py (#10442)
* Updated Comments on upper.py * Update upper.py * Update upper.py --------- Co-authored-by: Christian Clauss <[email protected]>
1 parent 1969259 commit f968dda

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: strings/upper.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
def upper(word: str) -> str:
22
"""
3-
Will convert the entire string to uppercase letters
3+
Convert an entire string to ASCII uppercase letters by looking for lowercase ASCII
4+
letters and subtracting 32 from their integer representation to get the uppercase
5+
letter.
46
57
>>> upper("wow")
68
'WOW'
@@ -11,10 +13,6 @@ def upper(word: str) -> str:
1113
>>> upper("wh[]32")
1214
'WH[]32'
1315
"""
14-
15-
# Converting to ascii value int value and checking to see if char is a lower letter
16-
# if it is a lowercase letter it is getting shift by 32 which makes it an uppercase
17-
# case letter
1816
return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word)
1917

2018

0 commit comments

Comments
 (0)