#Author:shijt

 china_map = {
"河北": {
'石家庄': ['辛集', '正定', '晋州'],
'邯郸': ['涉县', '魏县', '磁县'],
'衡水': ['饶阳', '安平', '深州']
},
"河南": {
'郑州': ['巩义', '新郑', '登封'],
'开封': ['兰考', '通许', '尉氏'],
'洛阳': ['宜阳', '孟津', '新安']
},
"山西": {
'太原': ['清徐', '阳曲', '古交'],
'大同': ['左云', '大同', '广灵'],
'晋城': ['泽州', '阳城', '泌水']
}
}
exit_flag=False
while not exit_flag:
for i1 in china_map:
print(i1)
choice1=input(">>>choice1:")
if choice1 in china_map:
while not exit_flag:
for i2 in china_map[choice1]:
print("\t"+i2)
choice2 = input("\t>>>choice2:")
if choice2 in china_map[choice1]:
while not exit_flag:
for i3 in china_map[choice1][choice2]:
print("\t\t"+i3)
choice3 = input("\t\t>>>choice3:")
if choice3 in china_map[choice1][choice2]:
print(choice3+"位于"+choice1+choice2)
elif choice3=="b":
break
elif choice3=="q":
exit_flag=True
elif choice2 == "b":
break
elif choice2 == "q":
exit_flag = True
elif choice1 == "q":
exit_flag = True
else:
print("input error")

级联菜单输出

05-11 02:11