Set level Three menu, then choose to print content, prompt selection, the last layer of prompt to return to the previous level or exit.
"' Three level menu to enter all levels ' ' Chinamenu = {" Recipes Daquan ": {" Homemade Recipes ": {" Home cooking ": {" sweet and sour Pork ribs "," braised Ribs "}," cold dishes ": {" Spicy chicken silk "," Cucumber Salad "}," snacks around ": {" Sichuan snacks ": {" Sichuan cold noodles ", "Spicy fragrant Pot"}, "Guangdong snacks": {"Shrimp sausage powder", "wonton noodle", "Meat fragrant glutinous Rice Regiment"}}, "Healthy diet": {"Diet Health": {"Home cooking": {"Sweet and sour Ribs", "Braised pork Ribs"}, "cold dishes": {"spicy shredded chicken", "cucumber Salad"}, "crowd meal": {" Pregnant women ": {" Pigeon soup "," braised pig Feet "}," maternity ": {" Pork knuckle ginger "," crucian carp soup "," Trotters peanut soup "}}}}exit_flag = Falsewhile not exit_flag:for i in Chinamenu:print (i) Bigmenu = Input ("Enter the column you want to enter:") if bigmenu in Chinamenu:while not exit_flag:for i in Chinamenu[bigmenu]:p rint (i) Smallmenu = Input ("Please enter the column you want to enter:") if smallmenu in Chinamenu[bigmenu]:while not exit_flag:for I in Chinamenu[bigmenu][smallmenu]: Print (i) Ultimatemenu = input ("Enter the column you want to enter:") if ultimatemenu in Chinamenu[bigmenu][smallmenu]:while not exit_flag:for I In Chinamenu[bigmenu][smallmenu][ultimatemenu]:p rint (i) Choice = input ("Already final column, please enter B to return, if need to exit please select Q:") if choice = = "B": Breakif Choice = = "Q": Exit_flag = Trueif Ultimatemenu = "B": breakif ultimatemenu = "Q": Exit_flag = trueif Smallmenu = = " B ": breakif Smallmenu = =" Q ": Exit_flag = trueif Bigmenu = =" B ": Breakif bigmenu = = "Q": Exit_flag = True
Python Three-level menu selection to enter all levels of the menu