[Tutor] case insensitivity

Christopher Spears cspears2002 at yahoo.com
Fri Sep 28 05:54:26 CEST 2007


I wrote a script that checks if two strings match. 
The script ignores case.

#!/usr/bin/env python

string_a = raw_input("Enter a string: ")
string_b = raw_input("Enter another string: ")

if cmp(string_a.lower(), string_b.lower()) == 0:
    print "The strings match!"
else:
    print "The strings don't match!"

Is this the best way to implement case insensitivity?

"I'm the last person to pretend that I'm a radio.  I'd rather go out and be a color television set."
-David Bowie

"Who dares wins"
-British military motto

"I generally know what I'm doing."
-Buster Keaton


More information about the Tutor mailing list