zoukankan      html  css  js  c++  java
  • python练习——moudule01——三级菜单

    '''
    作业2,三级菜单:
    1. 运行程序输出第一级菜单
    2. 选择一级菜单某项,输出二级菜单,同理输出三级菜单
    '''


    menu={
    '上海':{
    '徐汇区':{
    '卓挚',
    '腾讯'
    }
    },
    '南京':{
    '秦淮':{
    '东方航空',
    '朗诗'
    }
    },
    '盐城':{
    '大丰':{
    '森创',
    '阿胡苏'
    }
    }
    }

    #二逼青年版
    while True:
    for key1 in menu:
    print(key1)
    choice1=input('choice1>>:').strip()
    if choice1 == 'b' :break
    if len(choice1) == 0 or choice1 not in menu :continue

    while True:
    for key2 in menu[choice1]:
    print(key2)
    choice2 = input('choice2>>:').strip()
    if choice2 == 'b': break
    if len(choice2) == 0 or choice2 not in menu: continue

    while True:
    for key3 in menu[choice1][choice2]:
    print(key3)
    choice3 = input('choice3>>:').strip()
    if choice3 == 'b': break
    if len(choice3) == 0 or choice3 not in menu: continue

    #文艺青年版
    level=[]#保存上一级菜单,用于回退
    while True:
    for key in menu:
    print(key)
    choice=input('choice>>:').strip()
    if choice =='b':
    if len(level)==0:break
    menu=level[-1]
    level.pop()
    continue
    if len(choice) == 0 or choice not in menu :continue

    level.append(menu)

    menu=menu[choice]#改变menu内容
  • 相关阅读:
    沙漠之王(0/1分数规划+ 最小生成树)
    野餐规划(最小生成树性质)⭐
    走廊泼水节(最小生成树定理)⭐
    兄弟选择器+否定伪类
    子元素的伪类
    属性选择器
    伪元素
    伪类选择器
    Java连接Mysql由于版本更新报错
    Mac下安装SQL
  • 原文地址:https://www.cnblogs.com/Macal/p/6918793.html
Copyright © 2011-2022 走看看