Reputation: 175
Saying "n" to "Do you have a fever?" outputs False instead of prompting me for an answer to "Do you have a stuffy nose?". The other else statements work. Saying "y" to "Do you have a fever?", "n" to "Do you have a rash?", and "n" to "Does your ear hurt?" prints "Flu". I can't figure out why that one else statement doesn't work.
def part3():
if(raw_input("Do you have a fever? (y/n): ") == "y"):
if(raw_input("Do you have a rash? (y/n): ") == "y"):
print "Measles"
else:
if(raw_input("Does your ear hurt? (y/n): ") == "y"):
print "Ear Infection"
else:
print "Flu"
else:
if(raw_input("Do you have a stuffy nose? (y/n): " == "y")):
print "Head Cold"
else:
print "Hypochondriac"
Upvotes: 0
Views: 102
Reputation: 808
I found your mistake, and you are gonna hate yourself for it. This line
if(raw_input("Do you have a stuffy nose? (y/n): " == "y")):
should be
if(raw_input("Do you have a stuffy nose? (y/n): ") == "y"):
To explain a little more about why it printed false: "Do you have a stuffy nose? (y/n): " == "y" is evaluated to False, so it is like saying raw_input(False) which will print "False", but still get input
Upvotes: 10