import pygame # Homework: make the program quit when the player presses Escape. # Right now the only way to close the window is the X button. # Add an event check so that pressing Escape also sets running = False. # Hint: event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE pygame.init() screen = pygame.display.set_mode((640, 480)) pygame.display.set_caption("Quit on Escape") running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # TODO: add an elif here that quits when Escape is pressed screen.fill((50, 20, 70)) pygame.display.flip() pygame.quit()