20, python based learning -three_menu

. 1  # ! / Usr / bin / Python the env 
2  # __author: HLC 
. 3  # DATE: 2019/5/27 
. 4  
. 5  
. 6 MENU = {
 . 7      ' Beijing ' : {
 8          ' Haidian ' : {
 9              ' Wudaokou ' : {
 10                  ' SOHO ' : {},
 . 11                  ' YORK ' : {},
 12 is                  ' Google ' : {}
 13 is              },
 14              ' Zhongguancun ' : {
 15                 ' IQIYI ' : {},
 16                  ' car home ' : {},
 . 17                  ' the youku ' : {},
 18 is              },
 . 19              ' on the ground ' : {
 20                  ' Baidu ' : {}
 21              }
 22          } ,
 23          ' Changping ' : {
 24              ' River ' : {
 25                  ' old boys ' : {},
 26                  ' Northern ' : {}
 27              },
28              ' Tiantongyuan ' : {},
 29              ' huilongguan ' : {}
 30          }
 31          ' sun ' : {},
 32          ' East ' : {}
 33      }
 34      ' Shanghai ' : {
 35          ' minhang ' : {
 36              " people's Square " : {
 37                  ' fried chicken ' : {}
 38              }
 39          }
 40          ' Zhabei ' :
{
41             ' Train War ' : {
 42                  ' Cheng ' : {}
 43              }
 44          }
 45          ' Pudong ' : {}
 46      }
 47      ' Shandong ' : {}
 48  }
 49  
50 exit_flag = False
 51 is  the while  Not exit_flag:
 52 is      for Layer1 in MENU:
 53 is          Print (Layer1)
 54 is      choicel1 = iNPUT ( " Please enter: returns a layer [b, q exit: one]: ") .strip ()
 55      IF choicel1 in MENU:
 56 is          the while  Not exit_flag:
 57 is              for Layer2 in MENU [choicel1]:
 58                  Print (Layer2)
 59              choicel2 = INPUT ( " Please enter: returns a layer [b, q Exit:] Layer: " ) .strip ()
 60              IF choicel2 in MENU [choicel1]:
 61 is                  the while  Not exit_flag:
 62 is                      for Layer3 in MENU [choicel1] [choicel2]:
 63 is                          Print (Layer3)
 64                     the INPUT = choicel3 ( " Please enter: return to the previous [b, q quit: Layer 3: " ) .strip ()
 65                      IF choicel3 in the MENU [choicel1] [choicel2]:
 66                          the while  not exit_flag:
 67                              for layer4 in the MENU [choicel1] [choicel2] [choicel3]:
 68                                  Print (Layer4)
 69                              choicel4 = iNPUT ( " Please enter: returns a layer [b, q exit: four]: " ) .strip ()
 70                              IF choicel4 == " B " :
 71 is                                  BREAK 
72                              elif choicel4 =="q" :
73                                 exit_flag = True
74                     if choicel3 == "b":
75                         break
76                     elif choicel3 == "q":
77                         exit_flag = True
78             if choicel2 == "b":
79                 break
80             elif choicel2 == "q":
81                 exit_flag = True
82     if choicel1 == "b":
83         continue
84     elif choicel1 == "q":
85         exit_flag = True

 

Guess you like

Origin www.cnblogs.com/hlc-123/p/10941635.html