Python's three-tier menu

Source: Internet
Author: User

Three-level menu, based on the number selected by the user, into the sub-menu. First-level presentation.
1menu = {2     'Beijing': {3         "Chaoyang": {4             "CBD": ['CICC','CCTV'],5             "Jinrongjie": ["CT"],6             "Wangjing": ["Momo","Chuizi"]7         },8         "Haidian": ['Baidu','Youku']9     },Ten     'Shanghai': { One         "Pudong": ["Ctrip"," One Shop"], A         "Puxi": ["China Bank","America Bank"] -     } - } theExit_flag =False -  while  notExit_flag: -      forIndex, keyinchEnumerate (Menu.keys ()): -         Print(index, key) +Choice_1 = input ("Choose menu to enter:"). Strip () -     ifchoice_1.isdigit (): +Choice_1 =Int (choice_1) A  atKey_1 =list (Menu.keys ()) [Choice_1] -          while  notExit_flag: -              forIndex, keyinchEnumerate (menu[key_1]): -                 Print(' -', index, key) -choice_2 = input ("Choose menu to enter:"). Strip () -             ifchoice_2.isdigit (): inchoice_2 =Int (choice_2) -  toKey_2 =list (Menu[key_1].keys ()) [choice_2] +                  while  notExit_flag: -                      forIndex, keyinchEnumerate (menu[key_1][key_2]): the                         Print('-->-->', index, key) *Choice_3 = input ("Choose menu to enter:"). Strip () $                     ifchoice_3.isdigit ():Panax Notoginseng                         Print(" the ...") -                     elifChoice_3 = ='quit': theExit_flag =True +                     elifChoice_3 = =' Back': A                          Break the Else: +     Print("====going to quit====")
View Code

Note: This version is Python3.0 version

Python's three-tier menu

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.