дважды надо прописать exit. не пойму где ошибка
Если ввести "exit" - программа завершается как и должна. Если ввести buy - back - exit то программа снова выдаёт приветственную фразу из функции main и для завершения надо ещё раз ввести exit. Подскажите, пожалуйста, почему не срабатывает первый exit после buy - back
def remaining():
print("The coffee machine has:\n" +
str(water_tank) + " of water\n" +
str(milk_tank) + " of milk\n" +
str(coffee_tank) + " of coffee beans\n" +
str(cups_tank) + " of disposable cups\n" +
str(money_tank) + " of money\n")
def buy():
beverage = input("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:\n")
if beverage == "1":
print()
return espresso()
elif beverage == "2":
print()
return latte()
elif beverage == "3":
print()
return cappuccino()
elif beverage == "back":
main()
def fill():
global water_tank, milk_tank, coffee_tank, cups_tank
water_add = int(input("Write how many ml of water you want to add:\n"))
water_tank += water_add
milk_add = int(input("Write how many ml of milk you want to add:\n"))
milk_tank += milk_add
coffee_add = int(input("Write how many grams of coffee beans you want to add:\n"))
coffee_tank += coffee_add
cups_add = int(input("Write how many disposable coffee cups you want to add:\n"))
cups_tank += cups_add
print()
def take():
global money_tank
print("I gave you $" + str(money_tank))
print()
money_tank = 0
def espresso():
global water_tank, coffee_tank, cups_tank, money_tank
if water_tank >= 250 and coffee_tank >= 16 and cups_tank >= 1:
print("I have enough resources, making you a coffee!")
water_tank -= 250
coffee_tank -= 16
cups_tank -= 1
money_tank += 4
else:
print("Sorry, not enough water!")
def latte():
global water_tank, milk_tank, coffee_tank, cups_tank, money_tank
if water_tank >= 350 and milk_tank >= 75 and coffee_tank >= 20 and cups_tank >= 1:
print("I have enough resources, making you a coffee!")
water_tank -= 350
milk_tank -= 75
coffee_tank -= 20
cups_tank -= 1
money_tank += 7
else:
print("Sorry, not enough water!")
def cappuccino():
global water_tank, milk_tank, coffee_tank, cups_tank, money_tank
if water_tank >= 200 and milk_tank >= 100 and coffee_tank >= 12 and cups_tank >= 1:
print("I have enough resources, making you a coffee!")
water_tank -= 200
milk_tank -= 100
coffee_tank -= 12
cups_tank -= 1
money_tank += 6
else:
print("Sorry, not enough water!")
def main():
while True:
action = input("Write action (buy, fill, take, remaining, exit):\n")
if action == "exit":
break
elif action == "fill":
fill()
elif action == "take":
take()
elif action == "remaining":
remaining()
elif action == "buy":
buy()
water_tank = 400
milk_tank = 540
coffee_tank = 120
cups_tank = 9
money_tank = 550
main()