Skip to content

Updated Comments on upper.py #10442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions strings/upper.py
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)


Expand Down