cannot assign to lieteral

Asked 2 years ago, Updated 2 years ago, 37 views

    if not crash:
        for i in range(lane_count):
            pygame.draw.rect(screen, WHITE, [lanes[i][1], lane_width, lane_height])
            lanes[i][1] += 10
            if lanes[i][1] > WINDOW_HEIGHT:
                lanes[i][1] = -40 = lane_height

An error appears in the -40 number part here

error

2022-09-20 19:00

1 Answers

a = b = 10

The syntax is to assign 10 to the variable b and a to b.

In the code you've given us as an example, we'll try to assign the value of lane_height to -40 in -40=lane_height. However, -40 is a fixed value (literal), not a variable, so it cannot be assigned. That's why the error occurs.


2022-09-20 19:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.