Python String casefold() Method
casefold() method returns a string where all the characters are in lower case.
It is similar to the
lower() method, but the
casefold() method converts more characters into lower case.
For example, the German lowercase letter
'ß' is equivalent to
Since it is already lowercase, the lower() method would not convert it; whereas the
casefold() converts it to
casefold() method if your application supports globalization or localization.
Returns the lower case string.
The following example demonstrates the
mystr = 'TUTORIALS Teacher' print(mystr.casefold()) print('HELLO WORLD'.casefold())
tutorials teacher hello world
Symbols and Letters are not affected by the
If the string is in lower cases then
casefold() method will return original string.
mystr = '1# HarBOR Side' print(mystr.casefold()) mystr = 'Python is a programming language' print(mystr.casefold())
1# harbor side python is a programming language
The following example shows the difference between the lower() and
mystr = 'außen' print(mystr.casefold()) mystr = 'außen' print(mystr.lower())
In the above example, since ß is already lowercase, the
lower() method does nothing to it. But,
casefold() converts it to ss.