We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1969259 commit f968ddaCopy full SHA for f968dda
strings/upper.py
@@ -1,6 +1,8 @@
1
def upper(word: str) -> str:
2
"""
3
- Will convert the entire string to uppercase letters
+ 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.
6
7
>>> upper("wow")
8
'WOW'
@@ -11,10 +13,6 @@ def upper(word: str) -> str:
11
13
>>> upper("wh[]32")
12
14
'WH[]32'
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
18
return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word)
19
20
0 commit comments