In: Computer Science
import random #the menu function def menu(list, question): for entry in list: print(1 + list.index(entry),end="") print(") " + entry) return int(input(question))
plz explain this code
This code receives the list of menu options and display to the user and asks user to select the option and returns the user selected choice back to the calling function
Sample program:
import random
#the menu function
def menu(list, question):
for entry in list:
print(1 + list.index(entry),end="")
print(") " + entry)
return int(input(question))
menu(["Add ","Search","Exit"],"Select Choice?")
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me