I am watching a tutorial on pygame (made by Tech With Tim) and after following all the stuff with the run variable and the while run function, my window is still closing immediately. I have searched stackoverflow and the pygame forums but they all say stuff similar that doesn't work.
import pygame
WIDTH, HEIGHT = 900, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("First game")
BACKGROUND = (255, 255, 255)
def main():
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
WIN.fill(BACKGROUND)
pygame.display.update()
pygame.quit()
if __name__ == "__name__":
main()