Python String lower() Method
The lower()
method returns the copy of the original string wherein all the characters are converted to lowercase. If no uppercase characters present, it returns the original string. Symbols and numbers remain unaffected by this function.
Syntax:
str.lower()
Parameters:
None
Return Value:
Returns a string in lower case.
The following example demonstrates converting string to lowercase.
mystr = 'HELLO WORLD'
mystr_lower = mystr.lower()
print('Original String:', mystr)
print('New String:', mystr_lower)
Original String: HELLO WORLD
New String: hello world
The lower()
method will ignore numbers and symbols. The following example converts a string with a number and symbol to lowercase.
mystr = '#1 HarBour sIDe'
print(mystr.lower())
numstr = '12345'
print(mystr.lower())
numstr = '123ABC'
print(mystr.lower())
#1 harbour side
12345
123abc
The lower()
method does not convert all the Unicode chars. For example, the German lowercase letter 'ß' is equivalent to 'ss'. Since it is already lowercase, the lower() method would not convert it; whereas the casefold() converts it to 'ss'.
mystr = 'außen'
print(mystr.casefold())
mystr = 'außen'
print(mystr.lower())
aussen
außen