006 menu exercises (TAG bit), 006 ← ↓
Exit () is not required to exit the program ()
#01 code
1 #__ author: _ nbloser 2 # date: 3 4 5 shaoguan = ['renhua ', 'shixing', 'lechang ', 'nanxiong '] 6 jiangmeng = ['kaiping', 'pengjiang', 'taishan ', 'heshan', 'enping'] 7 guangdong_province = {'shaoguan ': shaoguan, 'jiangmen ': jiangmeng} 8 9 nanchang = ['donghu', 'xihu ', 'new', 'anyi', 'jinxian'] 10 jingdezhen = ['changjiang ', 'zhushan', 'upping', 'fuliang '] 11 jiangxi_province = {'nanchang': nanchang, 'jingdezhen ': jingdezhen} 12 13 provinces = {'guangdong': guangdong_province, 'jiangxi ': jiangxi_province} 14 15 def pr (Array): 16 for I in array: 17 print (I, end = "") 18 print () 19 20 while True: 21 print ("province :", end = "") 22 name_province = list (provinces. keys () 23 # print (name_province) 24 pr (name_province) 25 pro_input = input ("Enter the province you want to view/Enter exit to exit :") 26 if pro_input = 'exit ': 27 exit () 28 if pro_input not in pro_input: 29 print ("this province is not available! ") 30 continue31 while True: 32 tmp_province = provinces [pro_input] 33 name_shis = list (tmp_province.keys () 34 # print (tmp_province) 35 pr (name_shis) 36 shi_input = input ("enter the city you want to view/Enter exit/Enter return to the previous layer:") 37 if shi_input = 'eg': 38 exit () 39 if shi_input = 'Return ': 40 break41 if shi_input not in tmp_province: 42 print ("no city! ") 43 continue44 while True: 45 tmp_county = tmp_province [shi_input] 46 pr (tmp_county) 47 county_input = input (" Enter exit to exit/Enter return to the previous layer :") 48 if county_input = 'exit ': 49 exit () 50 if county_input = 'Return': 51 break
View Code