|

楼主 |
发表于 2021-10-17 08:43:41
|
显示全部楼层
不对,还是要强制取整
----------------------------------------------------
7
不妨猜一下小甲鱼现在心里想的是哪个数字:7
Traceback (most recent call last):
File "D:\Users\Desktop\222.py", line 15, in <module>
if guess < answer:
TypeError: '<' not supported between instances of 'int' and 'str'
>>>
""" 用Python设计第一个游戏 """
import random
guess = random.randint(1,10)
print(guess)
counts = 10
while counts > 0:
temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:")
answer = temp
if guess == answer:
print("你是小甲鱼心里的蛔虫嘛?!")
print("哼,猜中了也没奖励!")
break
else:
if guess < answer:
print("小啦~")
else:
print("大啦~")
counts = counts - 1
print("游戏结束,不玩啦^_^") |
|