加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

day07

发布时间:2020-12-20 10:43:40 所属栏目:Python 来源:网络整理
导读:# 猜年龄:age = 18count = 0 prize_dic = {'1': '布娃娃','2': '钢铁侠','3': '奥特曼','4': '裤子'} while count 3: guess = int(input('猜年龄')) if guess == 18: print('猜对了') print(prize_dic) for i in range(2): choice_prize = input('请选择你
# 猜年龄:
age = 18
count = 0
 prize_dic = {'1': '布娃娃','2': '钢铁侠','3': '奥特曼','4': '裤子'}
 while count < 3:
     guess = int(input('猜年龄'))
     if guess == 18:
         print('猜对了')
         print(prize_dic)
         for i in range(2):
             choice_prize = input('请选择你的奖品,不需要输入"n"退出')
             if choice_prize != "n":
                 print(f'恭喜你获得奖品:{prize_dic[(choice_prize)]}')
             else:
                 break
         break
     elif guess < age:
         print('猜小了')
     else:
         print('猜大了')
     count += 1
     if count !=3:
         continue
     again_choice = input('是否选择进行玩,y 继续 n 退出')
     if again_choice =='y':
         count = 0
# 三级菜单

menu = {
    '北京': {
        '海淀': {
            '五道口': {
                'soho': {},'网易': {},'google': {}
            },'中关村': {
                '爱奇艺': {},'汽车之家': {},'youku': {},},'上地': {
                '百度': {},'昌平': {
            '沙河': {
                '老男孩': {},'北航': {},'天通苑': {},'回龙观': {},'朝阳': {},'东城': {},'上海': {
        '闵行': {
            "人民广场": {
                '炸鸡店': {}
            }
        },'闸北': {
            '火车战': {
                '携程': {}
            }
        },'浦东': {},'山东': {},}

tag = True
while tag:
    menu1 =menu
    for key in menu1:
        print(key)
    choice1 = input('第一层>>:').strip()
    if choice1 == 'b':
        break
    if choice1 == 'q':
        tag =False
        continue
    if choice1 not in menu1:
        continue
    while tag:
        menu_2 =menu1[choice1]
        for key in menu_2:
            print(key)
        choice2 = input('第二层>>:').strip()

        if choice2 == 'b':
            break
        if choice2 == 'q':
            tag = False
            continue
        if choice2 not in menu_2:
            continue
        while tag:
            menu_3 =menu_2[choice2]
            for key in menu_3:
                print(key)

                choice3 = input('第三层>>:').strip()
                if choice3 == 'b':
                    break
                if choice3 == 'q':
                    tag = False
                    continue
                if choice3  not in menu_3:
                    continue
                while tag:
                    menu_4 = menu_3[choice3]
                    for key in menu_4:
                        print(key)

                    choice4 = input('第四层>>:').strip()
                    if choice4 =='b':
                        break
                    if choice4 == 'q':
                        tag = False
                        continue
                    if choice4 not in menu_4:
                        continue

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读