Why don’t my keypresses work in Pygame?

I don’t know why my attempt to read keypresses in Pygame is not working.

import pygame  pygame.init()    white = (255, 255, 255) green = (0, 255, 0) blue = (0, 0, 128) black = (0, 0, 0) red = (255, 0, 0)  w = 500 h = 500  x = 15 y = 480 vel = 5 screen = pygame.display.set_mode((w, h))  square = pygame.image.load(r'/Users/lanik2009/Downloads/square.PNG') square = pygame.transform.scale(square, (46, 40)) triangle = pygame.image.load(r'/Users/lanik2009/Downloads/triangle.PNG') triangle = pygame.transform.scale(triangle, (46, 40))  def player():     screen.fill(black)     pygame.draw.circle(screen,white, (15, 480), 10, 500)     screen.blit(triangle, (80, 460))     screen.blit(square, (180, 460))          running = True  while running:            for event in pygame.event.get():         if event.type == pygame.QUIT:             running = False      userInput = pygame.key.get_pressed()     if userInput[pygame.K_LEFT]:         x = -vel     if userInput[pygame.K_RIGHT]:         x = vel          player()     pygame.display.update()