"""
1. 给定年龄,用户可以猜三次年龄
2. 年龄猜对,让用户选择两次奖励
3. 用户选择两次奖励后可以退出
"""
import random
gift_list = '''
0: 单身汪
1: 尖叫鸡
2: 小猪佩奇
3: 小黄人
'''
gift_dict = {
'0': "单身汪",
'1': "尖叫鸡",
'2': "小猪佩奇",
'3': "小黄人"
}
gift_inp_dict = {}
age = random.randint(1, 100)
print(age)
count = 0
while count < 3:
age_inp = input('请输入年龄')
if not age_inp.isdigit():
print('傻逼,输错了!')
continue
age_inp_int = int(age_inp)
if age_inp_int < age:
print('猜小了')
elif age_inp_int > age:
print('猜大了')
else:
print('猜对了')
for i in range(2):
print(gift_list)
gift_inp = input('请输入您选择的奖品:
')
if gift_inp not in gift_dict:
print('最后一次机会
')
continue
giftod = gift_dict[gift_inp]
if giftod in gift_inp_dict:
gift_inp_dict[giftod] += 1
else:
gift_inp_dict[giftod] = 1
print(f'您共得到奖品为:{gift_inp_dict}')
break
count += 1