课堂三级菜单

import os



a = {
    "安徽": {
        "合肥" : {
            "合肥1":{},
            "合肥2":{},
            "合肥3":{},
            "合肥4":{},
        },
        "淮南" : {
            "淮南1":{},
            "淮南2":{},
            "淮南3":{},
            "淮南4":{},
        },
        "肥东" : {
            "肥东1":{},
            "肥东2":{},
            "肥东3":{},
            "肥东4":{},
        },
    },
    "河南": {
        "安阳" : {
            "安阳1":{},
            "安阳2":{},
            "安阳3":{},
            "安阳4":{},
        },
        "洛阳" : {
            "洛阳1":{},
            "洛阳2":{},
            "洛阳3":{},
            "洛阳4":{},
        },
        "开封" : {
            "开封1":{},
            "开封2":{},
            "开封3":{},
            "开封4":{},
        },
    },
    "河北": {
        "唐山": {
            "唐山1":{},
            "唐山2":{},
            "唐山3":{},
            "唐山4":{},
        },
        "北京": {
            "北京1":{},
            "北京2":{},
            "北京3":{},
            "北京4":{},
        },
        "天津": {
            "天津1":{},
            "天津2":{},
            "天津3":{},
            "天津4":{},
        },
    }
}

while True:
    for keys in a:
        print(keys)
    choice = input("1>>>")
    if choice in a:
        while True:
            for keys2 in a[choice]:
                print(keys2)
            choice2 = input("2>>>")
            if choice2 in a[choice]:
                while True:
                    for keys3 in a[choice][choice2]:
                        print(keys3)
                    choice3 = input("3>>>")
                    if choice3 == "返回":
                        break
                    elif choice3 == "退出":
                        exit()
            elif choice2 == "返回":
                break
            elif choice2 == "退出":
                exit()
    elif choice == "退出":
        exit()
原文地址:https://www.cnblogs.com/GhostCatcg/p/8099637.html