# Homework 32 solution, challenge: chessboard. # Run with: python exercises/32/homework/solutions/04-chessboard.py import pygame pygame.init() SIZE = 600 screen = pygame.display.set_mode((SIZE, SIZE)) pygame.display.set_caption("Chessboard") clock = pygame.time.Clock() LIGHT = (240, 217, 181) DARK = (181, 136, 99) CELLS = 8 cell = SIZE // CELLS running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False screen.fill((0, 0, 0)) for row in range(CELLS): for col in range(CELLS): color = LIGHT if (row + col) % 2 == 0 else DARK x = col * cell y = row * cell pygame.draw.rect(screen, color, (x, y, cell, cell)) pygame.display.flip() clock.tick(60) pygame.quit()