Level 3 menu

Source: Internet
Author: User
Level-3 menu date = {'beijing': {'haidian ': {'wudaokao': {'sogo': {}, 'netease ':{}, 'Google ': {'female ': 'Miss', 'handsome guy ': 'Duck' }}, 'zhongguancun ': {'iqiyi' :{}, 'car home ':{}, 'youku': {},}, 'shangdi ': {'Baidu' :{},},}, 'changping ': {'shahe ': {'old boy of huide mall ': {}, 'beihang' :{},}, 'tiantongyuan ':{}, 'huilongguan' :{},}, 'chaoyang ': {'chaoyang dama' :{}}, 'dongcheng ':{},}, 'shanghai': {'minhang': {"People's Square": {'fried chicken shop ': {'eat fried chicken in People's Square ':{}}}, 'zhabei': {'train barri': {'ctrip ':{}}, 'pudong ': {},}, 'shandong ': {'koryo' :{}},} flag = truewhile flag: for key in date: Print (key) nun = input ('Enter the city ') If nun = 'q': Flag = false if nun =' B ': break if nun in date: While flag: for I in date [nun]: Print (I) nun1 = input ('Please input ') If nun1 =' B ': break if nun1 in date [nun]: while flag: For I1 in date [nun] [nun1]: Print (I1) nun2 = input ('Please input ') If nun2 =' B ': break if nun2 in date [nun] [nun1]: While flag: For I2 in date [nun] [nun1] [nun2]: Print (I2) nun3 = input ('Please input ') If nun3 =' B ': break if nun3 in date [nun] [nun1] [nun2]: While flag: for I3 in date [nun] [nun1] [nun2] [nun3]: Print (nun3) nun4 = input ('Last line, input B, directly terminate ') if nun4 = 'B': Break
Level 3 menu, optimized version *************************************** *************
Flag = truenun = dateli = [] While flag: for key in Nun: Print (key) in_put = input ('Please input ') If in_put in Nun: Li. append (nun) nun = nun [in_put] If in_put = 'q': Li. pop () Flag = false if in_put = 'B': Break

 

Level 3 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.