我用的代码是:
from random import randintnum=randint(1,100)
print('guess what i think?')
answer=0
while answer!=num:
answer=int(input())
if answer<num:
print('too small')
if answer>num:
print('too big')
answer=int(input())
if answer==num:
print('bingo')
在运行的时候,有的时候会出现输入一个猜测的数字没反应的情况,要输第二遍甚至第三遍才有反应,如下:
guess what i think?
80
too small
90
too small
99
too big
95
95
too big
92
92
too small
93
too small
94
bingo