#! /usr/bin/env python # coding: utf-8 menu_options = { 1: 'Option 1', 2: 'Option 2', 3: 'Aide -- 3', 4: 'Exit', } def print_menu(): for key in menu_options.keys(): print (key, '--', menu_options[key] ) def option1(): print('Handle option \'Option 1\'') def option2(): print('Handle option \'Option 2\'') def option3(): f = open('aide001.txt', 'r') data = f.read() f.close print(data) if __name__=='__main__': while(True): print_menu() option = '' try: option = int(input('Enter your choice: ')) except: print('Wrong input. Please enter a number ...') #Check what choice was entered and act accordingly if option == 1: option1() elif option == 2: option2() elif option == 3: option3() elif option == 4: print('Thanks message before exiting') exit() else: print('Invalid option. Please enter a number between 1 and 4.')