My program is basically a talking calculator that calculates how many miles you get per tank of gas, and what not, it's a simple thing that popped into my head today! only problem is I got it all working, then when I decided to add a new little feature (something that calculates how many full tanks you need to go a certain amount of miles), but I keep getting the following error!
Traceback (most recent call last):
File "C:\Program Files\Python\gastanks.py", line 23, in <module>
c = input("Would you like to know how many full tanks you would need to get somewhere? ")
File "<string>", line 1, in <module>
NameError: name 'Yes' is not defined
Here is my syntax:
a = input("How many gallons of gas does your car hold? ") if a > 49: print "We're talking about cars here not space ships!" print "" else: print "Thank You!" print "" b = input("How many miles do you get per gallon? ") if b > 49: print "Ok you can stop lying now!" print "" else: print "Thank You!" print "" print "Now calculating how many miles per full tank.." from time import sleep sleep(4) print "You get", a*b,"miles per full tank!" print "" c = input("Would you like to know how many full tanks you would need to get somewhere? ") if c == Yes: print "Ok, here we go." else: print "Ok, goodbye now!"
Here is how everything works up until I get the error:
How many gallons of gas does your car hold? 26
Thank You!
How many miles do you get per gallon? 22
Thank You!
Now calculating how many miles per full tank..
You get 572 miles per full tank!
Would you like to know how many full tanks you would need to get somewhere? Yes
Traceback (most recent call last):
File "C:\Program Files\Python\firstprog.py", line 23, in <module>
c = input("Would you like to know how many full tanks you would need to get somewhere? ")
File "<string>", line 1, in <module>
NameError: name 'Yes' is not defined
Thanks in advance!
Edited by Daniel D, 19 January 2007 - 05:35 PM.