Answers for "python terminal menu"

0

python terminal menu

# python console helpMenu // OptionMenu
# Updated 2021 Oct 18 18:14
# Your Option Menu you can add more option for your needs.
# TODO Option Menu Below rename it to what the function will do.
# Example: your function will download something,
# Then you rename Option 1 To Download Something,

option_menu = {
	1: 'Option 1' , 
	2: 'Option 2',
	3: 'Exit' ,
}

# This function will print out your option menu
def print_options():
	
	for key in option_menu.keys():
		print(key , '---' , option_menu[key])

# Create your option functions here. / Add more for your needs
def option1():
	pass


def option2():
	pass



if __name__ == '__main__':
	
	while(True):

		print_options()

		option = ""

		try:
			# Edit 'Enter option' for your need.
			option = int(input('Enter option:'))

		except:

			print('option' , option)

		if option == 1:
			option1()
			#
			# Code here
			#
			# Also change the print massage. for your need
			print("OPTION1 WORKING....")

		elif option == 2:
			option2()
			#
			# Code here
			#
			# Also change the print massage. for your need
			print("OPTION2 WORING....")

		elif option == 3:
			# Set your Exit message here. for your need
			print("Exit code....")
			exit()

			# Set Your Error masage Here for your Need.
		else:
			print('invalid option:' , option ,'Try again...')
Posted by: Guest on October-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language