The casefold() function in python helps to convert the string to lowercase by removing all case distinctions present in the string. This is similar to the lower() method, but casefold() is more stronger and aggressive.
The casefold() method doesn't take any parameters. This method can find more matches when comparing two strings and can convert more characters to lowercase.
The return value is always a string. This method ignores cases at the time of string comparison.
string = "HOW ARE YOU" # print lowercase string print("After lowercase conversion:", string.casefold())
After lowercase conversion: how are you
string1 = "der Fluß" string2 = "der Fluss" # ß is equivalent to ss if string1.casefold() == string2.casefold(): print('The given strings are equal.') else: print('The given strings are not equal.')
The given strings are equal.
Note: German lowercase letter ß is already lowercase,casefold() converts it to ss, if lower() method is used it does nothing.