Blueherb In solitude, where we are least alone

三级菜单小程序


menu = {
    '北京':{
        '朝阳':{
            '天安门':{},
            '美女':{},
        },
        '海淀':{},
    },
    '吉林':{
        '长春':{},
        '辽源':{},
        '四平':{},
        '白城':{
            '镇赉':{},
            '洮南':{},
            '通榆':{}
        }
    },
    '辽宁':{
        '沈阳':{},
        '大连':{},
        '朝阳':{
            '北票':{},
            '建平':{},
            '龙城':{}
        }
    },
}
flag = False

while not flag:
    for i in menu:
        print(i)
    choice = input('1---->:')
    if choice in menu:
        while not flag:
            for j in menu[choice]:
                print(j)
            choice2 = input('2----->:')
            if choice2 in menu[choice]:
                while not flag:
                    flag = True
                    for m in menu[choice][choice2]:
                        print(m)
                    print('这已经是第三层菜单')
            elif choice2 == '上一层':
                break
            else:
                flag = True
                print('退出.....')

    elif choice == '上一层':
        break
    else:
        flag = True
        print('退出.....')

posted @ 2020-11-24 22:42  无敌-蹦蹦  阅读(57)  评论(0编辑  收藏  举报