python - I'm getting two errors whilst following this tutorial and I'm not very sure how to fix it (I'm a beginner)
问题描述
I was following a tutorial but kept receiving two errors once I reached a certain part. The errors were:
SyntaxError: cannot assign to function call
if score is > high_score:
^
SyntaxError: invalid syntax
The piece of code below is what included the errors
score += 1
if score is > high_score:
high_score = score
The error shown:
pen.write("Score: {} High Score: {}".format(score, high_score), align="center"), font=("College", 24, "bold"))
解决方案
It should be:
if score > high_score:
high_score = score
pen.write("Score: {} High Score: {}".format(score, high_score), align="center", font=("College", 24, "bold"))
You should remove 'is' from the code.
推荐阅读
- reactjs - 将 UI 克隆为只读版本 - React / mock API
- lisp - 球拍何时会在函数中检查结构的类型?
- c++ - 为什么我无法将对象 push_back 放入 C++ 多维向量中
- python - 具有中间值的 scipy odeint 非耦合向量方程
- arm - NUCLEO stm32L053R8 无法在寄存器级别将任何端口位设置为高/低
- sql - SQL语法实现LIKE的“对立面”
- json - 使用 pyspark 将数据框列转换为嵌套的 JSON 结构
- typescript - deno 捆绑的代码导致浏览器出错
- visual-studio-code - 在 VSCode 中展开单个方法
- three.js - threejs skinnedMesh 不允许多个实例