[Python] Why am I getting "UnboundLocalError local variable 'coffee_machine' referenced before...

Discussão em 'Python' iniciado por Stack, Março 31, 2025.

  1. Stack

    Stack Membro Participativo

    coffee_machine = True

    def user_input():
    while coffee_machine:
    user_choice = input("What type of coffee would you like espresso/latte/cappuccino?")
    if user_choice == "off".lower():
    coffee_machine = False
    x = []
    for ingredients in MENU[user_choice].get("ingredients").values():
    x.append(ingredients)
    print(x)

    user_input()

    Continue reading...

Compartilhe esta Página