[Tutor] Indentation Frustrations

nathan tech nathan-tech at hotmail.com
Wed Nov 18 19:19:53 EST 2020


Hey there,

Are you running this directly in the python command line?

If so, remove the blank lines.


You could also try copying your code into a file and then doing python 
file.py.


HTH

Nathan

On 18/11/2020 22:19, Nathaniel Dodson wrote:
> 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.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Ftutor&data=04%7C01%7C%7Ced0360d5c1eb47895fa908d88c1ead99%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637413410667952176%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=lkDa088Zq%2Ff1eLuK4v4A%2B6E0r8bHyqn2pm1lYR%2Fk6Fo%3D&reserved=0


More information about the Tutor mailing list