trying to make a interactive restaurant but in line 32 (total = menu1 * int(menu2)) im getting a error
Traceback (most recent call last): File "C:\Users\austi\OneDrive\Desktop\python\py.py", line 32, in total = menu1 * int(str(menu2)) ValueError: invalid literal for int() with base 10: '\n\tDrinks\n\t------\n\tCoke\n\tFanta\n\tSprite'
im new to python and cant figure this out please help
import time
name = input("Hello Welcome to McDicks.\nWhats Your Name?\n")
menu1 = ("""
Hot Off The Grill
-----------------
Burger With Fries
Double Pattey With Fries
------------------------
""")
menu2 = ("""
Drinks
------
Coke
Fanta
Sprite""")
if menu1 == "Burger With Fires" or menu1 == "burger with fries":
price = 5
if menu1 == "Doubel Pattey With Fries" or menu1 == "double patty with fires":
price = 10
if menu2 == "coke" or "fanta" or "sprite":
price = 2
total = menu1 * int(menu2)
if name == "cutter" or name == "Cutter":
fat_status = input("Are You Fat?\n")
if fat_status == "yes":
print("Get The Fuck Out YOU FAT FUCKER!!")
exit()
else:
print("Ok Good Come On In.")
else:
print("Ok " name "\nHere Is A Menu\n" menu "\nIll Be Back In A Minute\n")
time.sleep(5)
order = input("Hey " name " Are You Ready To Order?\n")
print("\nOk What Would You Like.")
yes = input()
print("\nOk Ill Be Back With Your Order.\n")
time.sleep(3)
print("Ok " name "\nHere Is Your \n" yes ".\n")
bill = input("Would You Like Your Bill ? ")
print("OK One Second.\n")
time.sleep(2)
print("Ok " name "Here Is Your Total $" str(total))
CodePudding user response:
You probably missing the input, change your code as the following:
menu1 = input("""
Hot Off The Grill
-----------------
Burger With Fries
Double Pattey With Fries
------------------------
""")
Same about menu2
CodePudding user response:
I think you forgot to add input
in the call to get value for menu1
and menu2
as @AKX mentioned. After getting the value, I see you're attempting to get the price value from menu1
and menu2
with a set of if
conditions, and assign price integer value to a single price
variable which will then be used to calculate total
value. I think you should avoid doing this since price
will be overwritten when check for values of menu2
and instead opt for having 2 separate variables to store price for menu1
and menu2
separately (price1
and price2
in below code)
import time
name = input("Hello Welcome to McDicks.\nWhats Your Name?\n")
menu1 = input("""
Hot Off The Grill
-----------------
Burger With Fries
Double Pattey With Fries
------------------------
""")
menu2 = input("""
Drinks
------
Coke
Fanta
Sprite
------
""")
price1, price2 = 0, 0
if menu1 == "Burger With Fires" or menu1 == "burger with fries":
price1 = 5
if menu1 == "Doubel Pattey With Fries" or menu1 == "double patty with fires":
price1 = 10
if menu2 == "coke" or "fanta" or "sprite":
price2 = 2
total = price1 price2