我的第一个python程序——猜数字

时间:2021-03-30 12:14:23
 #Author:xiaoxiao

 age = 22    #标准正确答案
counter = 0 #计数器
for i in range(10): #循环10次
if counter < 3:
guess_num = int(input('input your guess num:'))
if guess_num == age:
print('Congratulations! you got it.')
break #跳出整个循环
elif guess_num > age:
print('Think smaller...')
else:
print('Think Big...')
else:
continue_confirm = input('Do you want to continue y or n ?' )
if continue_confirm == 'y':
counter = 0
continue #跳出本次循环进入下次
else:
print('bye')
break
counter += 1