MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / lower

Function lower

strings/lower.py:1–20  ·  view source on GitHub ↗

Will convert the entire string to lowercase letters >>> lower("wow") 'wow' >>> lower("HellZo") 'hellzo' >>> lower("WHAT") 'what' >>> lower("wh[]32") 'wh[]32' >>> lower("whAT") 'what'

(word: str)

Source from the content-addressed store, hash-verified

1def lower(word: str) -> str:
2 """
3 Will convert the entire string to lowercase letters
4
5 >>> lower("wow")
6 'wow'
7 >>> lower("HellZo")
8 'hellzo'
9 >>> lower("WHAT")
10 'what'
11 >>> lower("wh[]32")
12 'wh[]32'
13 >>> lower("whAT")
14 'what'
15 """
16
17 # Converting to ASCII value, obtaining the integer representation
18 # and checking to see if the character is a capital letter.
19 # If it is a capital letter, it is shifted by 32, making it a lowercase letter.
20 return "".join(chr(ord(char) + 32) if "A" <= char <= "Z" else char for char in word)
21
22
23if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected