menu={‘china‘:{‘jx_province‘:{‘sr_manicipality‘:{‘yiyang_country‘:[‘qinghu_town‘,‘guifeng_town‘,‘wangli_town‘]},},},
‘American‘:{‘wathton.dc‘:{‘ei‘:{‘mi‘:[‘dei‘,‘dei‘,‘bue‘]},},},
‘Britian‘:{‘london‘:{‘ei‘:{‘mi‘:[‘dei‘,‘dei‘,‘bue‘]},},},
‘Rusian‘:{‘mosque‘:{‘ei‘:{‘mi‘:[‘dei‘,‘dei‘,‘bue‘]}}}
}
back_flag=False
exit_flag=False
while not back_flag and not exit_flag:
for key,v in enumerate(menu,1):
print(key,v)
choice=input(‘>>:‘).strip()
if choice in menu:
while not back_flag and not exit_flag:
for key2,v2 in enumerate(menu[choice]):
print(key2,v2)
choice2=input(‘2>>:‘).strip()
if choice2==‘b‘:
back_flag=True
if choice2==‘q‘:
exit_flag=True
break
if choice2 in menu[choice]:
while not back_flag and not exit_flag:
for key3,v3 in enumerate(menu[choice][choice2]):
print(key3,v3)
choice3=input(‘3>>‘).strip()
if choice3==‘b‘:
back_flag=True
if choice3==‘q‘:
exit_flag=True
break
if choice3 in menu[choice][choice2]:
for key4,v4 in enumerate(menu[choice][choice2][choice3],1):
print(key4,v4)
choice5=input(‘5>>‘).strip()
print(‘This is last level‘)
if choice5==‘b‘:
back_flag=True
if choice5==‘q‘:
exit_flag=True
break
else:
back_flag=True
else:
back_flag=False
else:
back_flag=Fals
python: practice three-level manu
原文:https://www.cnblogs.com/alansuny/p/12442644.html