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:
>   
Simpler:

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

>     print "The strings match!"
> else:
>     print "The strings don't match!"
>
> Is this the best way to implement case insensitivity?
Or if you are seeking ultimate terseness:

print "The strings " + ("don't", "")[string_a.lower() == string_b.lower()] + " 
match!"



_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to