首页 > 代码库 > 小实验2:三级菜单

小实验2:三级菜单

# Author:Alano

city = {
    "tianjin":{
        "Hedong":{
            "shiyijinglu":{"1"},
            "ergong":{"2"},
            "haihe":{"3"},
        },
        "Hexiqu":{
            "meiling":{},
            "Meiguihuayuan":{},
            "TJtushuguan":{},
        },
        "Hebeiqu":{
            "nankoulu":{},
            "Xukai":{},
            "Zhangyi":{},
        },
        },
    "beijing":{},
    "Hebeisheng":{},
 }

while True:
    for i in city:
        print(i)
    choice = input("Do you want to go >>>")
    if choice in city:
        while True:
            for i2 in city[choice]:
                print(i2)
            choice2 = input("Do you want to go >>>")
            if choice2 in city[choice]:
                while True:
                    for i3 in city[choice][choice2]:
                        print(i3)
                    choice3 = input("Do you want to go >>>")
                    if choice3 in city[choice][choice2]:
                        for i4 in city[choice][choice2][choice3]:
                            print(i4)
                            choice4 = input("Turn Back set (q)>>>")
                            if choice4 == "q":
                                break
                    if choice3 == "q":
                        break
            if choice2 == "q":
                break
    if choice == "q":
        print("This is top!")

 

小实验2:三级菜单