I can't seem to figure out what's wrong with this simple code. I have a user input and if it matches prints out 'That's good', if not prints out 'Too bad' but how can I get the input to ignore being case sensitive?

ans=raw_input("Are you feeling well today? ")
if ans == "yes":
    print "That's good"
else:
    print "Too bad"

I want it so if someone enters "YES" it will still print "That's good"

Recommended Answers

All 2 Replies

"YES" is not the same as "yes".

To rectify, convert the input to lower case. Something like:

ans=raw_input("Are you feeling well today? ")
if ans.lower() == "yes":
    print "That's good"
else:
    print "Too bad"

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.