Mar-27-2020, 12:11 PM
Hello friends I am new to pygame and python. The thing is I am not able to exit the python program even after I click the exit button on the pygame window. Here is my code:
And instead I get this as output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import pygame import sys pygame.init() WIDTH = 800 HEIGHT = 600 screen = pygame.display.set_mode((WIDTH, HEIGHT)) gameOver = False while not gameOver: for event in pygame.event.get(): if event. type = = pygame.QUIT: sys.exit() |
Output:Traceback (most recent call last):
File "/home/my-dell/dev/Documents/Programming projects/Practical_Python/atbsp.py", line 16, in <module>
sys.exit()
SystemExit
Thanks in advance. I am using Ubuntu 16.04 LTS.