Layer 1 menu

Print provincial, municipal and county levels menu

Go back one level

You can exit the program at any time

MENU = {
'Beijing': {
'Haidian': {
'Tsinghua': {},
'North': {}
},
'Changping': {
'River': {},
'Tiantongyuan': {},
'Huilongguan' : {}
}
}
'Shanghai': {
'minhang': {
'Shanghai generator plant': {},
'Shanghai turbine works': {},
' Shanghai boiler factory ": {}
},
'Matsue': {
'Donghua University': {
'school building': {},
'canteen': {},
'Library': {},
'hostel': {}
},
'Shanghai International Studies University': {},
'East China Politics and Law University ': {}
}
' Xuhui ': {
' Bainaohui ': {},
' Shanghai Jiaotong University ': {},
' Iron Mountain home ': {}
}
}
'Liaoning': {
'Shenyang': {
'WY': {},
'Xiang Xiang': {},
'West': {}
},
'Dalian': {
'Transportation.': {},
'Dalian Medical ": {}
}
' sun ': {
' two high ': {},
" Fourth ": {},
' board ': {},
' filling soup ": {},
'stewed intestines': {}
}
}
}

switch = True
while switch:
menu1 = menu

for key in menu1:
    print(key)
print('import back to last step,quit to end or choice to next step:')

choice1 = input('1 step:').strip()

if choice1 == 'back':
    break
if choice1 == 'quit':
    switch = False
    break
if choice1 not in menu1:
    continue

while switch:
    menu2 = menu1[choice1]

    for key in menu2:
        print(key)
    print('import back to last step,quit to end or choice to next step:')

    choice2 = input('2 step:').strip()


    if choice2 == 'back':
        break
    if choice2 == 'quit':
        switch = False
        break
    if choice2 not in menu2:
        continue

    while switch:
        menu3 = menu2[choice2]

        for key in menu3:
            print(key)

        print('import back to last step,quit to end or choice to next step:')

        choice3 = input('2 step:').strip()

        if choice3 == 'back':
            break
        if choice3 == 'quit':
            switch = False
            break
        if choice3 not in menu3:
            continue

Guess you like

Origin www.cnblogs.com/agsol/p/11515054.html