'python/pygame: AttributeError: module 'pygame' has no attribute 'event_get'

To test my pygame program, I wanted to make a green rectangle move using keyboard inputs, but when I run it, it crashes with: AttributeError: module 'pygame' has no attribute 'event_get' Here's the code:

player_x = 50
player_y = 50
display.fill(white)
pygame.draw.rect(display,green,(player_x,player_y,75,100))
pygame.display.update()
run = True
while run:
    for event in pygame.event_get():
      if(event.type == pygame.KEYDOWN):
         if(event.key == pygame.K_RIGHT):
             player_x += 10
screen.blit((player_x, payer_y))
pygame.display.update()              

#Exit game
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
          pygame.quit()
          sys.exit()

pygame.display.flip()
clock.tick(60)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source