-1

I'm not sure why I'm getting this error, since I'm fairly new to Python and Pygame, but based on my view of the code, it seems perfectly correct with no syntax error. I also seen the other similar issue to mine, but I've already incorporated the solutions to mine. Can someone please help me understand this issue?

    for event in pygame.event.get():
    if event.type == pygame.QUIT():
        sys.exit()

After I execute this program, it shows this message:(Picture)

If anyone has a solution, please let me know Thanks

  • 2
    Does this answer your question? [pygame.error: video system not initialized](https://stackoverflow.com/questions/26767591/pygame-error-video-system-not-initialized) – Lukas Neumann Dec 27 '20 at 15:48
  • 1
    after importing pygame, add this line to code `pygame.init()` – AmaanK Dec 27 '20 at 15:51
  • `pygame.QUIT` is not a function. It is an enumeration constant. `if event.type == pygame.QUIT():` must be `if event.type == pygame.QUIT:` – Rabbid76 Dec 27 '20 at 15:51

1 Answers1

0

pygame.QUIT is not a function. It is an enumeration constant. See pygame.event:

if event.type == pygame.QUIT():

if event.type == pygame.QUIT:
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • your answer is write, but also he is facing initialisation error for which he needs to initialise pygame. please add that to your answer – AmaanK Dec 27 '20 at 15:55
  • 1
    Better still flag for the dupe – SiHa Dec 27 '20 at 15:55
  • @xcodz-dot 1. I think we all know that. 2. No, the question is duplicate. It's a community wiki answer, however. Hence, anyone can extend it. – Rabbid76 Dec 27 '20 at 16:02