Case-Sensitivity in Python
How can I make Python recognise a string regardless of the case of it's contents? eg:
blah = [foo] diddle = raw_input() if diddle in blah: happy_dance() How can I get happy_dance() to run regardless of whether foo, Foo, FOo, FOO etc. is typed? Cheers, Dan |
Re: Case-Sensitivity in Python
Quote:
diddle = raw_input() if diddle in ["foo", "Foo", "FOo", "FOO"]: happy_dance() |
Just store all uppercase versions and then compare the upper()'ed version of the entered string to the things in the list.
Code:
>>> def acceptable(s): |
All times are GMT -5. The time now is 04:20 AM. |