day07work


# 猜年龄

```python
age = 18
count = 0
count1 = 0
count2 = 0
prize_msg = '''
0:充气娃娃
1:女朋友
2:男朋友
3:AD钙奶
4:iphone11
'''
prize_dict = {
    '0':'充气娃娃',
    '1':'女朋友',
    '2':'男朋友',
    '3':'AD钙奶',
    '4':'iphone11'
}
user_dict = {
    'nick':'123',
    'tank':'456',
    'robot':'789'
}
prize_list = {}

# while count < 3:
#     name = input('输入用户名: ').strip()
#     pwd = input('输入密码: ').strip()
while count1 <3:
    age_inp = input('请输入年龄: ').strip()
    if not age_inp.isdigit():
        print("沙雕,tmd输数字!")
        continue
    age_inp = int(age_inp)
    if age_inp > 18:
        print('dnmd猜大了!')
    elif age_inp < 18:
        print('dnmd猜小了')
    else:
        print('哎呦运气不错!')
        count1 = 9999
        while count2 < 2:
            print(prize_msg)
            prize_choice = input('请输入想要的奖品序号: ').strip()
            if prize_choice not in prize_dict:
                print('沙雕,没这个东西!')
                continue
            if not prize_choice.isdigit():
                print('沙雕,输数字!')
                continue
            if prize_dict[prize_choice] in prize_list:
                prize_list[prize_dict[prize_choice]] += 1
            else:
                prize_list[prize_dict[prize_choice]] = 1
            print(f'获得{prize_dict[prize_choice]}')
            count2 += 1
        print(f'你获得的奖品:{prize_list}')
    count1 += 1

posted on 2019-09-16 20:41  shenblogs  阅读(111)  评论(0)    收藏  举报

导航