python基础之作业3----三级菜单小练习

data = {
"华为技术":{
"产品与解决方案":{
"云核心网":{"云核心网研发管理部","云核心网平台开发部"},
"无线网络产品线":{"无线研发管理部","无线平台开发部" },
},
"2012实验室":{
"质量与运营部":{"上研质量与运营部","成研质量与运营部"},
},
"物联网":{
"车联网":{"车联网研发管理部","车联网开发管理部"},
},
},
} exit_flag = False # 默认不退出, while not exit_flag:
for i in data:
print(i)
user_choice = input("请选择您的一级SAP部门信息: ")
if user_choice in data:
while not exit_flag:
for j in data[user_choice]:
print("\t",j)
user_choice_2 = input("继续选择您的二级SAP信息: ")
if user_choice_2 in data[user_choice]: #[user_choice_2]:
while not exit_flag:
for k in data[user_choice][user_choice_2]:#[user_choice_3]:
print("\t\t",k)
user_choice_3 = input("继续选择您的三级SAP信息: ")
if user_choice_3 in data[user_choice][user_choice_2]:
for l in data[user_choice][user_choice_2][user_choice_3]:
print("\t\t",l)
user_choice_4 = input("达到最后一层了,返回请输入back:")
if user_choice_4 == "back":
break
elif user_choice_4 == "exit":
exit_flag = True
#pass 如果写pass,可以作为一个占位符,
if user_choice_3 == "back":
break
elif user_choice_3 == "exit":
exit_flag = True
if user_choice_2 == "back":
break
elif user_choice_2 == "exit":
exit_flag = True elif user_choice == "exit":
exit_flag = True
上一篇:转:【Java集合源码剖析】TreeMap源码剖析


下一篇:一年前的很水的渣网页(第一次html试水)