Python No.16_ Exercise (three level menu selection)

# !/ usr/bin/env python# -*-  coding:utf-8 - *-# A uthor:Hugolinhjdata =  {    'A':{        'Aa':{            'Aa1':{'oldboy':'test'},            'Aa2':{'lianjiadichan':'woaiwojia'}        },        'Ab':{            'Ab1':{'bengchi':'momo'},            'Ab2':{'CICC':'HP'},            'Ab3':{'Advent':'feixin'},        },    },     'B':{        'Ba':{            'Ba1':{'Ba11':'Ba12'}        },        'Bb':{            'Bb1':{'Bb11':'Bb12'},            'Bb2':{'Bb21':'Bb212'},        },        'Bc':{            'Bc1': {'Bc11': 'Bc12'},            'Bc2': {'Bc21': 'Bc212'},        },    },    'c':{        'Ca':{            'Ca1':{'Ca11':'Ca12'},             'Ca2':{'Ca21':'Ca12'},        },        'Cb':{            'Cb1': {'Cb11': 'Cb12'},            'Cb2': {'Cb21': 'Cb12'},        },        'Cc':{            'Cc1': {'Cc11': 'Cc12'},            'Cc2': {'Cc21': 'Cc12'},        },    }, }test = Falsewhile not test:    for i in data:        print(i)    choise = input('choise>>>')    if choise in data:        while not test:            for i2 in data[choise]:                print('\t', i2)            choise2 = input('choise>>>')            if choise2 in data[choise]:                while not test:                    for i3 in data[choise][choise2]:                        print('\t',  i3)                    choise3 = input('choise>>>')                    if choise3 in data[choise][choise2]:                        while not test:                            for i4 in data[choise][choise2][choise3]:                                print('\t', i4)                            choise4 = input('choise>>>')                            if choise4 in data[choise][choise2][choise3]:                                for i5 in data[choise][choise2][choise3][choise4]:                                    print('\t', I5) elif choise4 = ='q ': break elif choise4 = ='e': quit() else: Print ('You input wrong! Please re-enter ') elif choise3 = ='e': quit() elif choise3 = ='q ': break else: Print ('your input is wrong! Please re-enter ') elif choise2 = ='e': exit() elif choise2 = ='q ': break else:print ('What you input is wrong! Please re-enter ') elif choice = ='e': exit() elif choice = ='q ': break else: Print ('You entered wrong! Please re-enter ')

Recommended Today

Spring boot parsing Excel

Add dependency Note:Artifact ID is POI, which means it is suitable for the old version of office / Excel (2003 and earlier versions,.xls)*Artifact ID is poi OOXML, indicating the new version of office / Excel (2007 and later versions,.xlsx)* It is recommended to import dependencies according to the situation. If you are not sure to […]