1 #Author:xiaoxiao
2
3 age = 22 #标准正确答案
4 counter = 0 #计数器
5 for i in range(10): #循环10次
6 if counter < 3:
7 guess_num = int(input('input your guess num:'))
8 if guess_num == age:
9 print('Congratulations! you got it.')
10 break #跳出整个循环
11 elif guess_num > age:
12 print('Think smaller...')
13 else:
14 print('Think Big...')
15 else:
16 continue_confirm = input('Do you want to continue y or n ?' )
17 if continue_confirm == 'y':
18 counter = 0
19 continue #跳出本次循环进入下次
20 else:
21 print('bye')
22 break
23 counter += 1