猜年龄 v1.0

给定年龄,用户可以猜三次年龄

年龄猜对,让用户选择两次奖励

用户选择两次奖励后可以退出

age = 30
prize_dict = {0: 'durex', 1: 'okamoto', 2: 'Jissbon'}
count = 0

while count < 3:
guess = input('guess the age of nick:')
if not guess.isdigit():
print('cnm,give me a number please!')
continue
guess_int = int(guess)
if guess_int < age:
print('too young.')
elif guess_int > age:
print('too old.')
else:
print('bingo')
break

count += 1

for j in range(2):
user_choice = int(input(f'please choose a prize:\n{prize_dict} '))
print(f'Congradulations,you have got a mini size {prize_dict[user_choice]}')

print('game over')

posted @ 2019-09-12 19:04  Agsol  阅读(89)  评论(0编辑  收藏  举报