Level three Menu

Source: Internet
Author: User

#!/usr/bin/env python
#author: Lei
Import Collections
break = [' B ']
DIC = {
' Beijing ':
{' Haidian District ': [' zhongguancun ', ' Asian Games Village ', ' Tsinghua ', ' PKU '],
' Dongcheng District ': [' Dong Dan ', ' Beijing Station ', ' Chaoyang gate ', ' Galaxy Soho ']},
' Shanghai ':
{' Huangpu ': [' Huangpu 1 ', ' Huangpu 2 ', ' Huangpu 3 ', ' Huangpu 4 '],
' Pudong district ': [' Pudong 1 ', ' Pudong 2 ', ' Pudong 3 ', ' Pudong 4 '}
}

Order_dic = collections. Ordereddict (Sorted (Dic.items ()))
For k,v in Enumerate (Order_dic.keys ()):
Print (K+1,V)
#break_flag = False
While True:
Break_flag = False
Input_num = input ("Please enter a level two menu, enter Q to exit, enter B to exit to the previous level:"). Strip ()
If Len (input_num) ==0:continue
If Input_num in Break:break
if input_num = = ' Q ':
Break_flag = True
Break
new_input_num = Int (input_num)-1
If New_input_num <=1:
Key1 = sorted (Dic.keys ()) [New_input_num]
For K1,V1 in enumerate (Dic[key1]):
Print (K1+1,V1)
Else
Continue
While True:
Input_num_2 = input ("Please enter a level three menu sequence number, enter Q exit, enter B exit to the previous level:"). Strip ()
If Len (input_num_2) ==0:continue
If input_num_2 in Break:break
if input_num_2 = = ' Q ':
Break_flag = True
Break
new_input_num_2 = Int (input_num_2)-1
If new_input_num_2 <=1:
Key2 = sorted (Dic[key1].keys ()) [New_input_num_2]
For K2,v2 in enumerate (Dic[key1][key2]):
Print (K2+1,V2)
Else
Continue


If Break_flag is True:
Break
Else
Continue

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