二逼青年版:
while true: for key in menu: print(key) choice = input(>>>:) if len(choice) == 0: continue if choice not in menu:continue while true: for key2 in menu[choice]: print(key2) choice2 = input(>>>:) if len(choice2) == 0: continue if choice2 == b: break if choice2 not in menu[choice]: continue while true: for key3 in menu[choice][choice2]: print(key3) choice3 = input(>>>:) if len(choice3) == 0: continue if choice3 == b: break if choice3 not in menu[choice][choice2]: continue while true: for key4 in menu[choice][choice2][choice3]: print(key4) choice4 = input(>>>:) if len(choice4) == 0: continue if choice4 == b: break if choice4 not in menu[choice][choice2][choice3]: continue
文艺青年版:
current_level = menu last_level = [] while true: for key in current_level: print(key) choice = input(>>>:) if len(choice) == 0:continue if choice == b: if not last_level : break current_level = last_level[-1] last_level.pop() if choice not in current_level:continue last_level.append(current_level) current_level = current_level[choice]
作者:terry
blog:http://www.cnblogs.com/kkterry/
weibo:http://weibo.com/kkterry
e-mail:doubleginger@163.com
欢迎转载,还请标明出处!多谢多谢!
