Python String casefold() Method
The casefold() method converts all characters of the string into lowercase letters and returns a new string. This method is similar to lower(), but it also performs more aggressive case conversions for some characters that do not have a direct lowercase equivalent. For example:
text = "pYtHon"
# convert all characters to lowercase
lowercased_string = text.casefold()
print(lowercased_string) # Output: python
color1 = 'weiß' # German word for white
color2 = 'weiss'
print(color1 == color2) # False
print(color1.lower() == color2.lower()) # False
print(color1.casefold() == color2.casefold()) # True
If you have any questions about this code, you can drop a line in comment.
Comments
Post a Comment