import pygame import random pygame.init() window = pygame.display.set_mode((400, 500)) running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False color = (random.randint(0,255),random.randint(0,255),random.randint(0,255)) window.fill(color) pygame.display.flip() pygame.time.delay(1000)