| | |
Problem with simple if statement
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 43
Reputation:
Solved Threads: 0
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?
I want it so if someone enters "YES" it will still print "That's good"
Python Syntax (Toggle Plain Text)
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"
"YES" is not the same as "yes".
To rectify, convert the input to lower case. Something like:
To rectify, convert the input to lower case. Something like:
python Syntax (Toggle Plain Text)
ans=raw_input("Are you feeling well today? ") if ans.lower() == "yes": print "That's good" else: print "Too bad"
Last edited by scru; May 6th, 2009 at 11:56 am.
![]() |
Similar Threads
- SQL problem - simple? (Visual Basic 4 / 5 / 6)
- Problem with insert statement (ASP.NET)
- Winsock Sending problem (Visual Basic 4 / 5 / 6)
- simple 'if statement' issue (C#)
- problem for a simple asp.net query (ASP)
- having a problem with this simple program am going crazy (C)
- Simple If statement questions (Java)
- Problem with Switch statement ? (C++)
Other Threads in the Python Forum
- Previous Thread: validation logic
- Next Thread: How to locate a line in a text file
| Thread Tools | Search this Thread |
address alarm app beginner cipher cmd coordinates cx-freeze data decimals development dictionary directory dynamic error examples feet file float format function generator getvalue gui halp homework http images import input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse mysqldb number numbers output parsing path port prime programming projects push py2exe pygame pyglet pymailer pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation split sqlite ssh string strings sudokusolver terminal text thread threading time tlapse tooltip tuple tutorial ubuntu unicode url urllib urllib2 variable variables ventrilo vigenere web webservice wikipedia wx.wizard wxpython xlwt






