#!/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