2020-01-08 13:18:17 +00:00
|
|
|
def lower(word: str) -> str:
|
2020-05-22 06:10:11 +00:00
|
|
|
"""
|
2021-04-12 11:40:10 +00:00
|
|
|
Will convert the entire string to lowercase letters
|
2020-05-22 06:10:11 +00:00
|
|
|
|
2020-01-08 13:18:17 +00:00
|
|
|
>>> lower("wow")
|
|
|
|
'wow'
|
|
|
|
>>> lower("HellZo")
|
|
|
|
'hellzo'
|
|
|
|
>>> lower("WHAT")
|
|
|
|
'what'
|
|
|
|
>>> lower("wh[]32")
|
|
|
|
'wh[]32'
|
|
|
|
>>> lower("whAT")
|
|
|
|
'what'
|
|
|
|
"""
|
|
|
|
|
2023-10-13 15:55:32 +00:00
|
|
|
# Converting to ASCII value, obtaining the integer representation
|
|
|
|
# and checking to see if the character is a capital letter.
|
|
|
|
# If it is a capital letter, it is shifted by 32, making it a lowercase letter.
|
2020-09-25 17:58:40 +00:00
|
|
|
return "".join(chr(ord(char) + 32) if "A" <= char <= "Z" else char for char in word)
|
2020-01-08 13:18:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
from doctest import testmod
|
|
|
|
|
|
|
|
testmod()
|