我更改了步骤的值,但程序一遍又一遍地询问我的三明治输入。它应该更改 step 的值,以便程序可以退出第一个 while 循环并进入第二个 while 循环,但由于某种原因,第一个循环不断重复。
def main():
order = 0
step = 0
total = 0
while step == 0:
print ("Welcome to Jeremy's Meat Haven, please pick one drink, one salad, and one sandwitch.")
print ("Please select a sandwitch by inputting 1, 2, or 3")
print ("(1) Hamburger -$1.00") # Print the first option on the menu, and its price, for the user
print ("(2) Cheeseburger -$1.50") # Print the second option on the menu, and its price, for the user
print ("(3) Lambburger -$2.00") # Print the third option on the menu, and its price, for the user
order = input("What would you like to order? (enter number): ") # Prompt the user for the number on the menu of the item they want to order
if order == 1:
total = total + 1
step = step + 1
elif order == 2:
total = total + 1.5
step = step + 1
elif order == 3:
total = total + 2
step = step + 1
elif order != 1 or 2 or 3:
print ("please enter a valid value of 1, 2, or 3")
while step == 1:
print ("Please select a drink by inputting 1, 2, or 3")
print ("(1) milkshake -$1.00") # Print the first option on the menu, and its price, for the user
print ("(2) coke -$1.00") # Print the second option on the menu, and its price, for the user
print ("(1) lemonade -$1.00") # Print the third option on the menu, and its price, for the user
main()