English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The casefold() method returns a string with all characters in lowercase.
The casefold() method will deletein stringAll existing case distinctions exist. It is used for case-insensitive matching, that is, case is ignored when comparing.
This method is similar to the Lower() method, but the casefold() method is more powerful and more aggressive, which means it converts more characters to lowercase and finds more matches when comparing two strings converted by the casefold() method.
For example, German lowercase lettersßequivalent toss. However, due toßis already in lowercase letters, the lower() method does not work on it. However, casefold() converts it toss.
The syntax of casefold() is:
string.casefold()
The casefold() method does not take any parameters.
The casefold() method returns the string converted to lowercase.
string = "PYTHON IS AWESOME" # Print the lowercase string print("Lowercase string:", string.casefold())
When running the program, the output is:
Lowercase string: python is awesome
firstString = "der Flüss" secondString = "der Fluss" # ß is equivalent to ss if firstString.casefold() == secondString.casefold(): print('The strings are equal.') else: print('The strings are not equal.')
When running the program, the output is:
The strings are equal.