1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| import random times = shuzi = 3 suiji = random.randint(1,10) while times!= 0: if times==shuzi: tmp=input('Please enter a number:') else: tmp=input('Please enter again:') while not tmp.isdigit() : tmp=input('Enter a \'number\' again:') num=int(tmp) if num==suiji: print ('Yes\nend') times = times-times else : times= times -1 if times==0: print('Try too much\nthe answer is' ,suiji,'\nend') else: if num>suiji: print('too big') else: print('too small')
|