English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The casefold() method returns a string in which all characters are in lowercase.
The casefold() method will deletein stringall the differences in uppercase and lowercase exist. It is used for case-insensitive matching, that is, to ignore case when comparing.
This method is similar to the Lower() method, but the casefold() method is more powerful and 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ßis equivalent toss. However, sinceß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 Fluß" 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.