| | |
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
| Thread Tools | Search this Thread |
advanced aliased bash beginner bits calling casino changecolor class clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically events examples external file float format frange function google gui hints homework i/o iframe import info input java line linux list lists loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame pygtk python random rational raw_input recursion return scrolledtext signal singleton skinning stderr string strings subprocess table tails terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop windows word wxpython






