lundi 29 novembre 2021

Problem with running code and linking parts

def menu():
    print("1. Create new User")
    print("2. View User")
    print("3. Update User")
    print("4. Quit ") 
menu()

selection=input("Select a menu- Input a number:")

if not selection.isdigit():
    print("You have input a non digit value. Select again:")
    selection=input("Select a menu- Input a number:")
else:  
    selection = int(selection)
    if selection==1:
      print("::menu 1::")
      newName = input("Input first name : ")
      newSurname = input("Input last name : ")
    elif selection==2:
      print("::menu 2::")
    elif selection==3:
      print("::menu 3::")
    elif selection==4:
      print("you have logged out")
    else:
      print("There is no menu",end=" ")
      print(selection)
      print()
      menu()
      selection=input("Select a menu- Input a number:")

so when i run the code and input a wrong value first (non integer) then input a number that's not in the menu i want it to be able to let me to then input another number like a right one eg 1 but its seems it doesn't do anything after that and i don't know how to fix it can someone help. It only acknowledges 1-4 only when i do it first but not after any wrong values.

Aucun commentaire:

Enregistrer un commentaire