1 #Author:ersa2 " "3 Program: Level three menu4 Requirements:5 print provincial, city, and county level three menus6 can return to the upper level7 can exit the program at any time8 " "9menu = {Ten 'Beijing':{ One 'Haidian':{ A 'Five crossing':{ - 'Soho':{}, - 'NetEase':{}, the 'Google':{} - }, - 'Zhongguancun':{ - 'Iqiyi Art':{}, + 'Autohome':{}, - 'Youku':{}, + }, A 'on the ground':{ at 'Baidu':{}, - }, - }, - 'changping':{ - 'Shahe':{ - 'old boy':{}, in 'Beihang University':{}, - }, to 'Tin Tong Court':{}, + 'Huilongguan':{}, - }, the 'Chaoyang':{}, * 'Dongcheng':{}, $ },Panax Notoginseng 'Shanghai':{ - 'Minhang':{ the "People's square":{ + 'Fried Chicken Shop':{} A } the }, + 'Zhabei':{ - 'Train Warfare':{ $ 'Ctrip':{} $ } - }, - 'Pudong':{}, the } - }Wuyi theIs_continue =True - whileis_continue: Wu forIinchMenu: - Print(i) AboutChoice = input ("\ t chooses to go to the subordinate menu 1>>>:") $ - ifChoiceinchMenu: - whileis_continue: - forI2inchMenu[choice]: A Print("\ t", I2) +Choice2 = input ("\t\t choose to go to sub-menu 2>>>:") the ifChoice2inchMenu[choice]: - whileis_continue: $ fori3inchMenu[choice][choice2]: the Print("\t\t", i3) theChoice3 = input ("\t\t\t choose to go to sub-menu 3>>>:") the ifChoice3inchMenu[choice][choice2]: the whileis_continue: - forI4inchMenu[choice][choice2][choice3]: in Print("\t\t\t", I4) theChoice4 = input ("\t\t\t return to Superior: B exit: Q>>>:") the ifChoice4 = ="b": About Break the elifChoice4 = ="Q": theIs_continue =False the ifChoice3 = ="b": + Break - elifChoice3 = ="Q": theIs_continue =FalseBayi elifChoice2 = ="b": the Break the elifChoice2 = ="Q": -Is_continue =False - elifChoice = ='b': the Break the elifChoice = ="Q": theIs_continue = False
Python Road day2 Three-level menu of the dictionary exercises