Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # simple menu
- MENU_CHOICES = "1234x"
- while True: # menu loop
- while True: # validation loop
- choice = input('Enter choice 1-4 (or x to exit): ').lower()
- if choice and choice in MENU_CHOICES:
- break # break out of validation loop
- print('Not a valid choice, try again.')
- if choice == 'x': # break out of menu loop
- break
- if choice == "1":
- print('doing menu 1 stuff')
- elif choice == "2":
- print('doing menu 2 stuff')
- elif choice == "3":
- print('doing menu 3 stuff')
- else: # must be 4
- print('doing menu 4 stuff')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement