Article From:https://www.cnblogs.com/songzhixue/p/9124679.html
#__author:"SongZhiXue"
#date: 2018/6/2 0002


menu = {
    'Beijing':{
        'Sunrise':{
            'China World Trade Center':{
                'CICC':{},
                'HP':{},
                'Standard Chartered Bank':{},
                'CCTV':{},
            },
            'Wangjing':{
                'Stranger':{},
                'Benz':{},
                '360':{},
            },
            'Village':{
                'Uniqlo':{},
                'apple':{},
            },
        },
        'Changping':{
            'Shahe':{
                'Old boy':{},
                'Artest bun':{},
            },
            'Tian Tong Yuan':{
                'Chain family':{},
                'I love my family':{},
            },
            'Huilongguan':{},
        },
        'Haidian':{
            'Wudaokou':{
                'Google':{},
                'NetEase':{},
                'Sohu':{},
                'Sogou':{},
                'Quick hand':{},
            },
            'Zhongguancun':{
                'Youku':{},
                'Iqiyi':{},
                'Car home':{},
                'New Oriental':{},
                'tencent':{},
            },
        },
    },
    'Shanghai':{
        'Pudong':{
            'Lujiazui':{
                'CICC':{},
                'Goldman Sachs':{},
                'morgan':{},
            },
            'The Bund':{},
        },
        'Minhang':{},
        'Jingan':{},
    },
    'Shandong':{
        'Ji'nan':{},
        'Qingdao':{},
        'Texas':{
            'Leling':{
                'Ding Zhen Zhen':{},
                'City Proper':{},
            },
            'Plain county':{},
        },
    },
}
back_flag = False
exit_flag = False
while not back_flag and not exit_flag:
    for key in menu:
        print(key)
    choice1 = input('1>>>:').strip()
    if choice1 in menu:
        while not back_flag and not exit_flag:   #Let the program stop in the second layer
            for key2 in menu[choice1]:
                print(key2)
            choice2 = input('2>>>:').strip()
            if choice2 == 'b':
                back_flag = True
            if choice2 == 'q':
                exit_flag = True
            if choice2 in menu[choice1]:
                while not back_flag and not exit_flag:
                    for key3 in menu[choice1][choice2]:
                        print(key3)
                    choice3 = input('3>>>:').strip()
                    if choice3 == 'b':
                        back_flag = True
                    if choice3 == 'q':
                        exit_flag = True
                    if choice3 in menu[choice1][choice2]:
                        while not back_flag and not exit_flag:
                            for key4 in menu[choice1][choice2][choice3]:
                                print(key4)
                            choice4 = input('4>>>:').strip()
                            print('The last floor')
                            if choice4 == 'b':
                                back_flag = True
                            if choice4 == 'q':
                                exit_flag = True
                        else:
                            back_flag = False
                else:
                        back_flag = False
        else:
                back_flag = False

 

Similar Posts:

Link of this Article: Three level menu (Basic Edition)

Leave a Reply

Your email address will not be published. Required fields are marked *