| | |
Problem with simple if statement
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
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
Views: 294 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied apache application argv beginner book change code color dictionary dynamic edit editing enter examples excel file filename float format ftp function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql newb number numbers numeric output parameters parsing path phonebook port prime print program programming projects py2exe pygame pyopengl pyqt python random recursion recursive redirect remote reverse scrolledtext server session simple smtp software sprite ssh statictext string strings syntax table tennis terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython






