Im having some kind of mistake on my code that im making | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Im having some kind of mistake on my code that im making

Basically im making a game with pygame and as you can see by the code its only the beginning. But for some reason everything that i write past exit() comes as : code is unreachable. I am writing this code on pycharm. import pygame from sys import exit pygame.init() gjer = 1200 gjat = 700 ek = pygame.display.set_mode((gjer, gjat)) ora = pygame.time.Clock() while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit() screen.fill('black') pygame.display.update() ora.tick(60)

27th Nov 2021, 11:33 AM
Kane
Kane - avatar
9 Answers
+ 1
The problem is that everything after "exit()" is also after an infinite loop - "while true". So will never be reached indeed. Maybe you have to review the block structure. When did you expect these lines to run?
29th Nov 2021, 1:05 AM
Emerson Prado
Emerson Prado - avatar
0
Follow the easy way bro... Just simply import sys and Write sys.exit() in ur code.
27th Nov 2021, 11:36 AM
Ramprasad
Ramprasad - avatar
0
Oh i have done and still its the same problem
27th Nov 2021, 11:39 AM
Kane
Kane - avatar
0
Try removing pygame.quit() And only use sys.exit().
27th Nov 2021, 11:41 AM
Ramprasad
Ramprasad - avatar
0
I have done that too i feel like it has to be a problem with pycharm
27th Nov 2021, 11:42 AM
Kane
Kane - avatar
0
I think u have some indention errors in last lines of code... Try changing them... If it doesnt work even then.. Pycharm in ur device has problem
27th Nov 2021, 11:48 AM
Ramprasad
Ramprasad - avatar
0
I see... Well thank u
27th Nov 2021, 12:28 PM
Kane
Kane - avatar
0
Its okay i fixed it. I should only have done in the beginning a= true While a ... ... ...
29th Nov 2021, 8:40 AM
Kane
Kane - avatar
0
Okay this was a mistake. Killing myself is my only option now.
29th Nov 2021, 8:37 PM
Kane
Kane - avatar