Updated lower and upper (#2468)

* update lower and upper

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Du Yuanchao
2020-09-26 01:58:40 +08:00
committed by GitHub
parent e92cd9d5c5
commit 72fe611462
2 changed files with 2 additions and 9 deletions

View File

@ -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__":