zoukankan      html  css  js  c++  java
  • python:practice Advanced three-level menu

    menu={'jx':{'shangrao':{'yiyang':{'zuoshenwei':{'staff':69,'money':9002869},
    'haungjia':{'landscape':'beatiful','dog':4}
    },
    'hengfeng':{},
    'yangshang':{},
    },
    'yingtang':{'yugan':{},
    'yiangtanshi':{}
    },
    'ganzhou':{'ei':{},
    'ei':{}
    },
    },
    'gx':{'nanning':{},
    'liuzhou':{},
    'guiling':{},
    },
    'hn':{'yueyan':{},
    'hangyang':{},
    'huaihua':{},
    },
    'gd':{'guangzhou':{},
    'jiangmen':{},
    'shengzheng':{},
    'fosheng':{}
    }}
    current_layer=menu
    parent_layer=[]
    while True:
    for key,value in enumerate(current_layer,1):
    print(key,value)
    choice=input('>>>').strip()
    if len(choice)==0:
    continue
    if choice in current_layer[choice]:
    parent_layer.append(current_layer)
    current_layer=current_layer[choice]
    elif:choice=='b':
    if parent_layer:
    current_layer=parent_layer.pop()
    else:
    print('invalid character for your input')


    usage:
    current:at present layer to loop.to implement advanced fuction
    The programe work more concise and clear ,precise







  • 相关阅读:
    Paths on a Grid
    Three Kingdoms(优先队列+bfs)
    Factstone Benchmark(数学)
    C. Searching for Graph(cf)
    B. Trees in a Row(cf)
    String Successor(模拟)
    乘积最大的分解(数学)
    Kindergarten Election
    In 7-bit
    Friends
  • 原文地址:https://www.cnblogs.com/alansuny/p/12443909.html
Copyright © 2011-2022 走看看