码迷,mamicode.com
首页 > 其他好文 > 详细

day1_作业2(三级菜单)--改进版

时间:2018-05-05 15:31:26      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:浙江省   江苏省   was   usr   not   int   coding   作业2   杭州   

#!/usr/local/bin/python3
# -*- coding:utf-8 -*-
province={
    ‘江苏省‘:{
        ‘南京市‘:[‘秦淮区‘,‘玄武区‘,‘栖霞区‘],
        ‘苏州市‘:[‘姑苏区‘,‘虎丘区‘,‘吴中区‘],
        ‘无锡市‘:[‘滨湖区‘,‘惠山区‘,‘锡山区‘]
    },
    ‘浙江省‘:{
        ‘杭州市‘:[‘西湖区‘,‘拱墅区‘,‘萧山区‘],
        ‘温州市‘:[‘鹿城区‘,‘瓯海区‘,‘龙湾区‘],
        ‘宁波市‘:[‘镇海区‘,‘海曙区‘,‘江北区‘]
    }
}
while True:
    print("hello,which province do you want to choose?")
    for i in province:
        print(i)
    province_choose=input("-->")
    while True:
        if province_choose in province.keys():
            print("which city do you want to choose?")
            for j in province[province_choose]:
                print(j)
            city_choose=input("-->")
            while True:
                if city_choose in province[province_choose].keys():
                    print("here are the areas:")
                    for k in province[province_choose][city_choose]:
                        print(k)
                    area_choose=input("-->")
                    while True:
                        if area_choose in province[province_choose][city_choose]:
                            print("there is nothing to show...")
                            break
                        elif area_choose==‘q‘:
                            exit()
                        elif area_choose==‘r‘:
                            break
                        else:
                            print("your choice was unexist!")
                            break
                elif city_choose==‘r‘:
                    break
                elif city_choose==‘q‘:
                    exit()
                else:
                    print("your choice was unexist!")
                    break
                if area_choose==‘r‘:
                    break
        elif province_choose==‘q‘ or province_choose==‘r‘:
            exit()
        else:
            print("your choice was unexist!")
            break
        if city_choose==‘r‘:
            break

  

day1_作业2(三级菜单)--改进版

标签:浙江省   江苏省   was   usr   not   int   coding   作业2   杭州   

原文地址:https://www.cnblogs.com/octopuszy/p/8994673.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!