Computer >> Computer tutorials >  >> Programming >> Python

How do I do a case insensitive string comparison in Python?


The following code is an example of case insensitive string comparison in Python.

Example

string1 = 'Star Wars'
string2 = 'star wars'
if string1.lower() == string2.lower():
    print "The strings are case insensitive"
else:
    print "The strings are not case insensitive"

Output

This code gives the following output

The strings are case insensitive