mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Updated Comments on upper.py (#10442)
* Updated Comments on upper.py * Update upper.py * Update upper.py --------- Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
parent
1969259868
commit
f968dda5e9
|
@ -1,6 +1,8 @@
|
|||
def upper(word: str) -> str:
|
||||
"""
|
||||
Will convert the entire string to uppercase letters
|
||||
Convert an entire string to ASCII uppercase letters by looking for lowercase ASCII
|
||||
letters and subtracting 32 from their integer representation to get the uppercase
|
||||
letter.
|
||||
|
||||
>>> upper("wow")
|
||||
'WOW'
|
||||
|
@ -11,10 +13,6 @@ def upper(word: str) -> str:
|
|||
>>> upper("wh[]32")
|
||||
'WH[]32'
|
||||
"""
|
||||
|
||||
# Converting to ascii value int value and checking to see if char is a lower letter
|
||||
# if it is a lowercase letter it is getting shift by 32 which makes it an uppercase
|
||||
# case letter
|
||||
return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user