[Tutor] case insensitivity

Kent Johnson kent37 at tds.net
Fri Sep 28 14:07:59 CEST 2007


Christopher Spears wrote:
> 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:

if string_a.lower() == string_b.lower():

> Is this the best way to implement case insensitivity?

As far as I know.

Kent


More information about the Tutor mailing list