"' Mutselect of the place name.1.1-3 to three layer2. ' Q " to exit.3." B " to back.4.other words to retry." kyewords= (' 1 ', ' 2 ', ' 3 ', ' Q ', ' Q ') placename={"Liaoning": {"Dalian":("high-tech", "Zhongshan"), "Shenyang":("Tiexi", "Hun nan"), "Huludao":("Lotus Mountain", "Xingcheng")}, "Jilin": {"Changchun":("Dawa", "Gao Tian"), "siping":("Er River", "Lu Yang"), "Tongliao":("Tonghua", "Underworld")}, "Heilongjiang": {"Hal":("Pingshan", "Yang"), "daqing":("Black Oil", "thousand"), "Mohe":("Russia", "northernmost")}}def province (placename): #提取省份到列表 ProvinceList=[] j=1 for i in placename.keys (): provincelist=provincelist+[i] print (J, '. ', i) j+=1 return (provincelist) def jugdeinput (inputlist): proname= "" &Nbsp; prvalue=input ("please select provide number,press ' Q ' to exit:") if prvalue== ' 1 ' : proname= inputlist[0] elif prvalue== ' 2 ': proname=inputlist[1] elif prvalue== ' 3 ': proname=inputlist[2] elif prvalue== ' q ' or prvalue== ' Q ': print ("Tuichu") Return (' 0 ') elif prvalue== ' B ' or prvalue== ' B ': return ('-1 ') else: return print ("You select%s, the following is its 1 sub-region:"%proname) return (ProName) While true: &nbsP Provincelists=province (placename) aaaa=jugdeinput (provincelists) if aaaa== ' 0 ': break elif placename.__contains__ (AAAA): cityname=placename[aaaa] while True: citylists=province (CityName) bbbb= jugdeinput (citylists) if bbbb== ' 0 ': aaaa= ' 0 ' break elif Cityname.__contains__ (BBBB):  &Nbsp; countrylist=cityname[ bbbb] for name in countrylist: print (name) while True: lastvalue=input ("Please press ' B ' to return or ' Q ' to quit: ") if lastvalue== ' Q ' or lastvalue== ' Q ': bbbb= ' 0 ' aaaa= ' 0 ' break elif lastvalue== ' B ' or lastvalue== ' B ': break else: continue elif bbbb== '-1 ': break if aaaa== ' 0 ': break if aaaa== ' 0 ': Breakprint (' This query has ended! ')
Python's List,dict method is not fully recorded and needs to be strengthened. I do not know why 3.0 is not compatible with 2.0, reading all look mixed, we must pay attention!
This article comes from "Looking back on the empty" blog, so be sure to keep this source http://yishi.blog.51cto.com/1059986/1978271
Python Authoring Region selection-dict