Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkutaj/8cfab7e2d76fb2e1e549e4db46c46820 to your computer and use it in GitHub Desktop.
Save pkutaj/8cfab7e2d76fb2e1e549e4db46c46820 to your computer and use it in GitHub Desktop.
2023-03-08-How-to-Create-a-Simple-Menu-in-Python-Scripts1.py
# menu_maker.py
class Terminal_Menu:
def __init__(self, menu_items: list):
self.menu_items = menu_items
def print_menu(self):
for i, single_item in enumerate(self.menu_items, start=1):
print(i, single_item)
def select_menu_item(self):
selection_prompt = "Select a number of an item (e.g. 1): "
selection = input(selection_prompt)
return self.menu_items[int(selection) - 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment