menu = { "深圳":{ "罗湖":{ "罗湖火车站": {}, "东门": {}, "国贸": {}, "布心": {}, }, "福田":{ "香蜜湖": {}, "华强北": {}, "华强南": {}, "市民中心": {}, }, "南山": { "南山中心城": {}, "南头关": {}, "华侨城": {}, }, "宝安": { "宝安中心": {}, "西乡": {}, "松岗": {}, }, "龙岗": { "龙岗中心城": {}, "布吉": {}, "坂田": {}, }, }, "湖南":{ "长沙": { "大学城区":{}, }, "衡阳":{ "衡阳":{ "火车站":{}, }, }, "郴州":{ "北湖区": {}, "苏仙区": {}, "东湖区": {}, }, }, "北京":{}, } back_flag = False exit_flag = False while not back_flag and not exit_flag: for key in menu: print(key) choice = input("please choose the address:").strip() if choice in menu: while not back_flag and not exit_flag: for key2 in menu[choice]: print(key2) choice2 = input("please choose the address").strip() if choice2 == "b": back_flag = True if choice2 == "q": exit_flag = True if choice2 in menu[choice]: while not back_flag and not exit_flag: for key3 in menu[choice][choice2]: print(key3) choice3 = input("please choose the address").strip() if choice3 == "b": back_flag = True if choice3 == "q": exit_flag = True if choice3 in menu[choice][choice2]: while not back_flag and not exit_flag: for key4 in menu[choice][choice2][choice3]: print(key4) choice4 = input("please choose the address").strip() print("last layer") if choice4 == "b": back_flag = True if choice4 == "q": exit_flag = True break else: back_flag = False else: back_flag = False else: back_flag = False