Try it here
Subscribe
Python String casefold()

Case Insensitive comparison in Python

case_insensitive_comparison_in_python

To do case insensitive comparison in Python use string's casefold() function.

Python String casefold()

The casefold() method removes all case distinctions present in a string. It is used for Case Insensitive matching.

Syntax:

string.casefold()

There is no parameters required for casefold() function and it returns the casefolded string.

Example1:

 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
>>>

Writer profile pic

Uk01 on Dec 15, 2015 at 12:12 am


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.



Post Comment

Comments( 0)

×

Forgot Password

Please enter your email address below and we will send you information to change your password.