Print province, city, and county level three menu can return to the previous level can exit the program at any time
__author__="Alex Li"Data= { 'Beijing':{ "changping":{ "Shahe":["Oldboy","Test"], "Tin Tong Court":["Chain Home Property","I love my family ."] }, "Chaoyang":{ "Wangjing":["Mercedes","mo Mo"], "Guomao":{"CICC","HP"}, "Dong Zhi men":{"Advent","fetion"}, }, "Haidian":{}, }, 'Shandong':{ "Texas":{}, "Qingdao":{}, "Jinan":{} }, 'Guangdong':{ "Dongguan":{}, "Changshu":{}, "Foshan": {},},}exit_flag=False while notExit_flag: forIinchData:Print(i) Choice= Input ("choose to enter 1>>:") ifChoiceinchData: while notExit_flag: forI2inchData[choice]:Print("\ t", I2) Choice2= Input ("choose to enter 2>>:") ifChoice2inchData[choice]: while notExit_flag: fori3inchData[choice][choice2]:Print("\t\t", i3) Choice3= Input ("choose to enter 3>>:") ifChoice3inchData[choice][choice2]: forI4inchData[choice][choice2][choice3]:Print("\t\t", I4) Choice4= Input ("last layer, press B to return to >>:") ifChoice4 = ="b": Pass elifChoice4 = ="Q": Exit_flag=TrueifChoice3 = ="b": Break elifChoice3 = ="Q": Exit_flag=TrueifChoice2 = ="b": Break elifChoice2 = ="Q": Exit_flag= True
Python Level Three Menu example