代码如下
import random
sNum = random.randint(1, 20)
print('这是一个1~20之间的数字')
for number in range(0,4):
print('请输入猜测的数字')
guess = int(input())
if guess == 0:
break
if guess < sNum:
print('太小啦')
elif guess > sNum:
print('太大啦')
else:
break
if(guess == sNum):
print('猜对啦,真厉害,就是',str(guess))
else:
print('很遗憾,真正的答案就是',str(sNum))