Recently I was trying to make a pygame program, and first I made a blank screen that closes when you hit the red X button (hey, I gotta start somewhere). I ran my program, and a trackback error popped up saying my video system was not initialized. Here is my code below:
import pygame
#initialize pygame and make the screen
pygame.init()
screen = pygame.display.set_mode((1000,600))
#main program loop
running = True
while running:
#check for exit
for event in pygame.event.get():
if event.type == pygame.quit():
running = False
Notice how in line 4, I specifically typed "pygame.init()." I ran the code, and this error popped up:
Traceback (most recent call last):
File "C:\Users\13027\Desktop\Hackathon Files\main.py", line 22, in <module>
for event in pygame.event.get():
pygame.error: video system not initialized
It says that my video system was not initialized, even though I did pygame.init() in line 4. Is there anything else I should've done, or am I using the wrong version of Python (I'm using 3.8)? Thank you in advance.
Ok so I just realized my error and I'm going to fix it. On line 13, where it says
if event.type == pygame.quit():
I got the syntax wrong and the code should have been
if event.type == pygame.QUIT:
Fix the code like that, and there should be no error.