首页 > 解决方案 > 学习使用 Minecraft (Python) 编程中的代码不起作用

问题描述

我对编程完全陌生。我有这本书 Learn To Program With Minecraft: Transform Your World With The Power of 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'

我不明白这个错误信息是什么意思,也不明白为什么这本书的代码不起作用。谁能帮我?

标签: pythonminecraftlogical-operators

解决方案


推荐阅读