I have a simple script which asks the user for their meal price and adds tax to it. my question is, how can I make it so the user can input "yes"
and "no"
instead of an integer like 0
or 1
?
Here is the code:
a = input("what is the price of your meal?") #self explanatory
print (float(a) * 0.08) #calculates tax
print ("Is the price of your tax") #prints tax
b = input("do you want me to add the tax to your total meal price? press 0 for yes and 1 for no") #asks user if they would like to have tax added to the meal price
if b == str(0): #yes they want tax added
print ("The price of your meal is...")
print ((float(a) * 0.08) + float(a)) #adds tax and initial meal price together
elif b == str(1): #no they do not
print ("Your loss.")
else: #if they did not choose 0 or 1
print ("I asked for 0 or 1")
c = input("will that be all? 0 for yes 1 for no")
if c == str(0):
print ("thank you for coming!")
elif c == str(1):
print ("what else do you need?")
else:
print ("this is a yes or no question")
d = imput("Let me repeat this, what else do you need?")
if d == str(nothing):
print ("begone then")
elif d == str(you):
print ("yuck...")
else:
print ("You either want nothing, or me. choose.")