# 需求:
# 1. 系统随机出一个数字,用户需要猜是多少;
# 2. 需要反馈用户猜的数字是大了还是小了;
# 3. 用户只有3次猜测机会;
import random
key = random.randint(1, 10)
print('-----------Game Start-----------')
temp = input('guess a number between 1~10, you have 3 chances: ')
guess = int(temp)
i = 2
while (guess != key) and (i > 0):
if guess > key:
print('no no no, your number is bigger ~~~')
else:
print('no no no, your number is smaller ~~~')
temp = input('guess again, you still have ' + str(i) + ' chance to guess: ')
guess = int(temp)
i -= 1
if guess == key:
print('congras, you are right !')
else:
print('oops, still wrong, what a pity')
print('-----------Game Over-----------')
print('')
print('the answer is: ' + str(key))