python--Implementation of Level three menu selection (original)

Source: Internet
Author: User

#coding: utf-8dict={' Beijing ': {' haidingqu ': [' Qinghe ', ' Keji '], ' chaoyangqu ': [' Q ', ' W ']}, ' Shandong ': {' liaochen ': [' Chiping ', ' Yanggu '], ' Dezhou ': [' e ', ' R ']}}for index,i in Enumerate (dict):        #首先循环显示一级菜单   print index,i,   print ' Exit Q '        #后补上的退出功能, added to the dictionary to show the trouble, simply first display, in the submenu of the exit function through the individual variable assignment implementation exit, A= '!q '        #退出变量赋值, value you casually up, as long as you understand while a!= ' Q ':         #判断是否键入了退出字符    title=raw_input (' Enter the city name you want to enter: ')    if Title.isalpha ():         #判断输入的是否是纯字符串       if Dict.has_ Key (title):        #判断键入的值在字典中 for          index,i in enumerate (Dict[title]):             print index,i         #显示输入城市的详细信息          Dict=dict[title]         #当前所在菜单及子菜单赋值       elif title== ' q ':           #判断键入的是不是退出字符           a= ' q '            #赋值, terminating the loop       Else:           print ' input is wrong, please re-enter! '                  elif title== ' q '       : #判断键入的是不是退出字符        a= ' q '          #赋值, terminating the loop        else:   print ' exited '

  

python--Implementation of Level three menu selection (original)

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.