diff --git a/strings/lower.py b/strings/lower.py index a1bad44c7..b7abe9fc9 100644 --- a/strings/lower.py +++ b/strings/lower.py @@ -1,5 +1,4 @@ def lower(word: str) -> str: - """ Will convert the entire string to lowecase letters @@ -9,7 +8,6 @@ def lower(word: str) -> str: 'hellzo' >>> lower("WHAT") 'what' - >>> lower("wh[]32") 'wh[]32' >>> lower("whAT") @@ -19,9 +17,7 @@ def lower(word: str) -> str: # converting to ascii value int value and checking to see if char is a capital # letter if it is a capital letter it is getting shift by 32 which makes it a lower # case letter - return "".join( - chr(ord(char) + 32) if 65 <= ord(char) <= 90 else char for char in word - ) + return "".join(chr(ord(char) + 32) if "A" <= char <= "Z" else char for char in word) if __name__ == "__main__": diff --git a/strings/upper.py b/strings/upper.py index 2c264c641..411802a2a 100644 --- a/strings/upper.py +++ b/strings/upper.py @@ -8,7 +8,6 @@ def upper(word: str) -> str: 'HELLO' >>> upper("WHAT") 'WHAT' - >>> upper("wh[]32") 'WH[]32' """ @@ -16,9 +15,7 @@ def upper(word: str) -> str: # converting to ascii value int value and checking to see if char is a lower letter # if it is a capital letter it is getting shift by 32 which makes it a capital case # letter - return "".join( - chr(ord(char) - 32) if 97 <= ord(char) <= 122 else char for char in word - ) + return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word) if __name__ == "__main__":