How do I fix pygame.error: video system not initialized in replit

Question:

I’m playing around with Pygame, and when I clicked Run for the first time, Pygame gives me the error

pygame.error: video system not initialized

How do I fix this?

The code I have at the moment is

import pygame

pygame.init()

white = (255, 255, 255)
green = (0, 255, 0)
blue = (0, 0, 128)
X = 400
Y = 400
display_surface = pygame.display.set_mode((X, Y))
pygame.display.set_caption('Epic SAVER')
font = pygame.font.Font('freesansbold.ttf', 32)
text = font.render('Epic SAVER', True, green, blue)
textRect = text.get_rect()
textRect.center = (X // 2, Y // 2)

while True:
    display_surface.fill(white)
    display_surface.blit(text, textRect)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
    pygame.display.update()

I’m running this in Replit, and how would I fix this?
I got this off of the internet because I don’t know Pygame that well

Asked By: Wolfieboy09

||

Answers:

replit.com allows creating Python/PyGame scripts and multiplayer coding. When creating a new repl, select the Pygame template:

Answered By: Rabbid76
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.