day07作业

age_count = 0
age = 18
prize_dict = {
'0': "芭比娃娃",
'1': "变形金刚",
'2': "psp游戏机",
'3': "奥特曼",
'4': "遥控飞机",
'5': "chongqiwawa",
}
prize_msg = '''
0 芭比娃娃
1 变形金刚
2 psp游戏机
3 奥特曼
4 遥控飞机
5 chongqiwawa
'''
get_prize_dict = {}
while age_count < 3:
age_inp = input('请输入你的年龄:').strip()
if not age_inp.isdigit():
print('傻吊,你活了aaa岁吗?')
continue
age_inp_int = int(age_inp)
if age_inp_int > age:
print('猜大了')
elif age_inp_int < age:
print('猜小了')
else:
print('猜对了')
prize_count = 0
while prize_count < 2:
print(f'奖品如下:{prize_msg}')
prize_choice = input('请选择你需要的奖品:')
prize = prize_dict[prize_choice]
if prize in get_prize_dict:
get_prize_dict[prize] += 1
else:
get_prize_dict[prize] = 1
print(f'恭喜你获得奖品{prize}')
prize_count += 1
print(f'总共获得奖品为:{get_prize_dic}')
break
age_count += 1

原文地址:https://www.cnblogs.com/xwjhyy/p/11530155.html