[Tutor] Indentation Frustrations

Nathaniel Dodson natesmokes420yall at gmail.com
Wed Nov 18 17:19:48 EST 2020


Please, for the love of God, why am I constantly getting indentation errors
when I'm trying to write some simple Pygame code? I have Googled the error
messages and it says my indentation has to be uniform. But it is for Pete's
sake! I'm ripping my hair out bc I'm not copying and pasting the code; I'm
typing it line for line from a tutorial. I get to a certain point and it
just gives me indentation error after indentation error. This is the code,
and when I get to the part to assign keyboard key functions for movement,
it gives me "expected an indented block" error (and always highlights the
"i" in the if statement in red):

import pygame
pygame.init()

win = pygame.display.set_mode((500, 500))
pygame.display.set_caption("First Game")

x = 50
y = 50
width = 40
height = 60
vel = 5

run = True

while run:
    pygame.time.delay(100)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    keys = pygame.key.get_pressed()

    if keys[pygame.K_LEFT]:

    if keys[pygame.K_RIGHT]:

I'm not getting what's going on. I know about mixing tabs with spaces, and
I'm not doing that. That's what I learned through Googling the issue.


More information about the Tutor mailing list