Advertisement
earlution

menu

Jun 30th, 2022
828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. menu = True
  2. answer = ""
  3. while menu:
  4.     print("1. Option 1")
  5.     print("2. Option 2")
  6.     print("3. Option 3")
  7.     print("4. Sub-menu")
  8.     print("X. Exit/Quit")
  9.     answer = input("What would you like to do? ")
  10.     print()
  11.     if answer == "1":
  12.         print("you chose option 1")
  13.         print()
  14.     elif answer == "2":
  15.         print("you chose option 2")
  16.         print()
  17.     elif answer == "3":
  18.         print("you chose option 3")
  19.         print()
  20.     elif answer == "4":
  21.         answer4 = True
  22.         while answer4:
  23.             print("You chose the sub-menu:")
  24.             print("1. you chose option 4.1.")
  25.             print("2. you chose option 4.2.")
  26.             print("3. you chose option 4.3")
  27.             print("X. exit/quit")
  28.             print()
  29.             answer = input("What would you like to do? ")
  30.             if answer == "1":
  31.                 print("Option 4.1")
  32.                 print()
  33.             elif answer == "2":
  34.                 print("Option 4.2")
  35.                 print()
  36.             elif answer == "3":
  37.                 print("Option 4.3")
  38.                 print()
  39.             elif answer.lower() == "x":
  40.                 print("\nGoodbye")
  41.                 answer4 = None
  42.             else:
  43.                print("\n Not Valid Choice Try again")
  44.     elif answer.lower() == "x":
  45.         print("\nGoodbye")
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement