首页 > 解决方案 > 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"))

标签: python

解决方案


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.


推荐阅读