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

PythonServer Side ProgrammingProgramming

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
raja
Published on 28-Dec-2017 11:43:54
Advertisements