How to make user to return to main menu in python 3?
I am making a repl that has a main menu and has many options. And I need help with making the user to return to main menu. I tried something like:
Input = input("Enter '1' to return to main menu:")
if Input == '1':
In this example, the "mainMenu" module is just a module that has all the options and it will take you back to the main menu. But it does not work. So how do I make the user go back to the main menu? In my repl below, if you try option 1, then return to main menu, nothing happens! Why does this happen?
Oh you missed the parentheses in Choice1.py. There should be parentheses next to MainM.Run.
Here is a fixed version
if Choice == 'y': import MainM MainM.Run() else: print("Goodbye")
Hope this helped :)
I don’t know about this mainMenu, what i do is this:
back_to_main_menu = True while back_to_main_menu == True: [your code here for main menu]
Then after, when you want to go back to main menu, for example:
action = input(“press 1 to go back to menu”) if action == “1”: back_to_main_menu = True
And it should take u back to Main menu
please mark this comment as the answer if it helped you :)