《学习如何使用Minecraft编程(Python)》一书中的代码不起作用

时间:2020-08-16 13:55:22

标签: python minecraft logical-operators

我对编程完全陌生。我有一本书,学会用Minecraft编程:用Python的力量改变世界。这本书没有真正的客户支持。

我正在学习逻辑运算符顺序。本书以以下代码为例:

wolves = input("Enter the number of wolves: ")
enoughWolves = wolves > 10 and wolves < 20
print("Enough wolves: " + str(enoughWolves))

我完全按照书中的描述编写了代码,但是出现了以下错误:

Traceback (most recent call last):
  File "/Users/myName/Documents/wolves.py", line 3, in <module>
    enoughWolves = wolves < 20
TypeError: '<' not supported between instances of 'str' and 'int'

我不明白此错误消息的含义,也不了解为什么书中的代码不起作用。谁能帮我吗?

0 个答案:

没有答案