[Tutor] Indentation Frustrations
Mats Wichmann
mats at wichmann.us
Wed Nov 18 19:17:53 EST 2020
On 11/18/20 3:19 PM, Nathaniel Dodson wrote:
> 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.
a statement that introduces a block (ones that end with a colon) have to
actually have an indented block. Those two don't. Python doesn't know
for sure it's an error before it sees a line that can't be correct,
which would be the second "if" statement from the included snip.
If you're developing iteratively and want a placeholder to avoid those
kinds of errors you can use "pass" (traditional) or the ellipsis
operator ... as in:
if keys[pygame.K_LEFT]:
pass
if keys[pygame.K_RIGHT]:
...
More information about the Tutor
mailing list