直接附上代码吧
import random
secret=random.randint(1,20)
guess=int(input("猜一下我心里想的那个数:"))
while guess!=secret:
print("哎呀,猜错了,请重新输入吧:")
guess=int(input("哎呀,猜错了,请重新输入吧:"))
if guess==secret:
print("猜对了诶")
else:
if guess>secret:
print("大了大了")
else:
print("小了小了")
else:
print("恭喜你,猜对了")
print("游戏结束")
python语言要注意格式