Apologies for the confusing title, but here is a very simplified version of what I mean:
def main():
burger = 0
shake = 0
run = True
while run:
choice = show_menu()
if choice == "burger":
qt_burger += 1
elif choice == "shake":
qt_shake += 1
else:
show_bill
def show_menu():
choice = input("Burger or Shake?: ")
if choice not in ["burger", "shake"]:
show_error(choice)
else:
return choice
def show_error(choice):
print(f"{choice} is not an option")
show_menu()
main()
Function 'main' defines variable 'choice' based on what is returned from function 'show_menu'. If show_menu does not call show_error, the program properly returns the input value back to 'choice' in 'main'. However, if show_error is called, show_menu is called again, and a proper value is entered the second time, choice in main becomes 'none'. Is there any way around this while keeping all these separate functions? I have also tried re-calling show_menu from within itself rather than from within the error function, but it is the same result.