I am learning Python and I have an issue: I'm trying to develop a simple program which shows a menu and stores choices. Based on choices (taken from input) opens another menu which does the same thing and so on. My problem is that once login is done I get into main_menu but once there, whatever choice I make (1,2,3,4 and so on) I always get stuck in main menu, no redirect is done to another menu.
Below part of the code:
import os, sys
import print_data
import user_op
def check_login():
username = user_op.login()
if username is not None:
main_menu(username)
def main_menu(user):
os.system('cls')
print ("Benvenuto %s"%(user))
print ("Cosa Vuoi fare?")
print ("1. Visualizza Lista Film Disponibili")
print ("2. Visualizza Lista Prenotazioni Attive")
print("3. Visualizza Lista Prenotazioni Passate")
print("4. Prendi in Prestito un Film")
print("5. Restituisci un Film")
print ("0. Quit")
choice = input(" >> ")
if choice == 1:
lista_film(user)
elif choice == 2:
active_bookings_list(user)
elif choice == 3:
inactive_bookings(user)
elif choice == 4:
prendi_in_prestito(user)
elif choice == 5:
restituisci(user)
elif choice == 0:
exit()
else:
print("Scelta non valida. Riprova...")
main_menu(user)
def exit():
sys.exit()
def lista_film(user):
os.system('cls')
print("Ecco la Lista dei Film attualmente disponibili: ")
print_data.print_movies()
print(os.linesep)
print("Ora Cosa Vuoi fare? ")
print("9. Indietro")
print("0. ESCI")
choice = input(" >> ")
if choice == 9:
main_menu(user)
elif choice == 0:
exit()
As example: If in main_menu I type '1'
I should get lista_film menu right?
Well, on the Terminal something happens, but it is so fast I cannot see what's going on, in something like 0,2 secs I get back into main_menu.
This thing happens for any other choice, even if I type a random string.
I'm sure you guys are more experienced than me, so could you explain me why this issue occurs and how to solve it?
Thank you very much