python字典作业_python第一天作业:字典

作业三:多级菜单

三级菜单

可依次选择进入各子菜单

所需新知识点:列表、字典

break_flag = False

count = 0

while not break_flag:

print("111111层")

while not break_flag:

print("222222222层")

while not break_flag:

print("3333333层")

count += 1

if count > 10:

break_flag =True

print("keep")

menu = {

'浙江':{

'杭州':{

'西湖':{

'西溪',

'三墩'},

'滨江':{'滨和', '高新'}

},

'丽水':{

'龙泉':{'宝剑', '瓷器'},

'青田':{'石雕', '华侨'},

'缙云':{'烧饼', '木雕'},

},

},

'山东':{

'烟台':{'大海', '日照'},

'青岛':{'平度', '黄岛'},

'东营':{'利津', '垦利'}

},

'广东':{

'深圳':{'南山', '福田'},

'梅州':{'五华', '兴宁'},

'佛山':{'三水', '桂城'}

}

}

ext_flage= False

while not ext_flage:

for lev1 in menu:

print(lev1)

choice = input("lev1>>:").strip()

if len(choice) == 0: continue

if choice == "b":break

if choice == "q":

ext_flage = True

if choice in menu[choice]:

while not ext_flage:

for lev2 in menu[choice]:

print(lev2)

choice2 = input("lev2>>:").strip()

if len(choice2) == 0 :continue

if choice2 == "b":break

if choice2 == "q":

ext_flage = True

if choice2 in menu[choice][choice2]:

while not ext_flage:

for lev3 in menu[choice][choice2]:

print(lev3)

choice3 = input("lev3>>:").strip()

if len(choice3)== 0: continue

if choice3 =="b":break

if choice3 =="q":

ext_flage = True

if choice3 in menu[choice][choice2][choice3]:

while not ext_flage:

for lev4 in [choice][choice2][choice3]:

print(lev4)

choice4 = input("lev4>>:").strip()

if len(choice4) == 0 : continue

if choice3 == "b" :break

if choice3 == "q" :

ext_flage = True

continue

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值