To do case insensitive comparison in Python use string's casefold() function.
The casefold() method removes all case distinctions present in a string. It is used for Case Insensitive matching.
string.casefold()
There is no parameters required for casefold() function and it returns the casefolded string.
string = "Python casefold EXAMPLE"
# print lowercase
print(string.casefold())
Result:
python casefold example
Example2:
>>> string1 = "This is Python's case sensitive Matching Example" >>> string2 = "This is python's case sensitive matching example" >>> string1 == string2 False >>> string1.casefold() == string2.casefold() True >>>
If you like dEexams.com and would like to contribute, you can write your article here or mail your article to admin@deexams.com . See your article appearing on the dEexams.com main page and help others to learn.