Python Three-level menu selection to enter all levels of the menu

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.