Quantcast
Channel: How do I do a case-insensitive string comparison? - Stack Overflow
Viewing all articles
Browse latest Browse all 16

Answer by Patrick Harrington for How do I do a case-insensitive string comparison?

$
0
0
def insenStringCompare(s1, s2):""" Method that takes two strings and returns True or False, based        on if they are equal, regardless of case."""    try:        return s1.lower() == s2.lower()    except AttributeError:        print "Please only pass strings into this method."        print "You passed a %s and %s" % (s1.__class__, s2.__class__)

Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>