Indentation error


#1
# 1 - Import library
import dis
import pygame
from pygame.locals import *

def mariogame(mario):

# 2 - Initialize the game
pygame.init()
width, height = 640, 480
screen = pygame.display.set_mode((width, height))

# 3 - Load images
mario = pygame.image.load("Desktop/mario.png")
")
player = mario.get_rect()

# 4 - keep looping through
while 1:
    # 5 - clear the screen before drawing it again
    screen.fill((255,255,255))
    #6 - draw the screen elements
    screen.blit(mario, player)
    # 7 - update the screen
    pygame.display.flip()
    # 8 - loop through the events
    for event in pygame.event.get():
        # check if arrow keys are pressed
        if event.type == pygame.KEYDOWN:
            player = player.move(0,-5)
        elif event.key == pygame.K_DOWN:
            player = player.move(0,5)
        elif event.key == pygame.K_RIGHT:
            player = player.move(5,0)
        elif event.key == pygame.K_LEFT:
            player = player.move(5, 0)

dis.dis(mariogame)

Some indentation error in this code Help me


#2

Any block of code inside of something like a function definition or a conditional flow statement ought to be indented.

def my_function(x):
  do_some_stuff
  if test:
    do_some_other_stuff
  else:
    do_nothing_else

You don’t appear to have indented your function. :slight_smile: