Я изменил значение шага, но программа продолжает снова и снова вводить мой сэндвич-вход. Предполагается изменить значение шага так, чтобы программа могла выйти из первого цикла while и ввести второй цикл while, но по какой-то причине первые циклы продолжают повторяться.Хотя цикл в python сохраняет повторы, несмотря на удовлетворительное условие
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()
В этом отступлении определенно что-то не так, вы смешиваете вкладки и пробелы? –
Вы ошибаетесь в табуляторе –
Да, ваше отступы - это немного беспорядок, поэтому трудно сказать, является ли это преднамеренным или плохим вырезом и пастой. Пожалуйста, вы можете исправить? – Kev