First of all, I apologize for what is probably a VERY noob question.
That being said, I would like to understand why Python sometimes target a ":" in a script and throws the "invalid syntax" error. It usually happens after I add some stuff to the script, and then it keeps saying that putting a ":" after an "if" statment is wrong.
To verify how this happens, I created a different "if" statment to put in the place in which the old one was, and the error still happened. I also tried to copy-paste the "if" statment in another script, and it worked.
for event in pygame.event.get():
The line above was located in line 35 of the following script:
import pygame, sys display_width = 800 display_height = 600 BLUE = (0,0,255) DISPLAY = pygame.display.set_mode ((display_width,display_height)) Player_img = pygame.image.load("spacecore.png") clock = pygame.time.Clock() Player_Img = pygame.image.load("role.png") def game_loop(): Game = True while Game == True: pygame.display.update() DISPLAY.fill(BLUE) clock.tick(60) def player(x,y): DISPLAY.blit(Player_Img,(x,y)) mod_x = mod_y = 0 x += mod_x y += mod_y player((10,100) for event in pygame.event.get(): if event.type == pygame.key.get_pressed(): if event.key == pygame.K_LEFT: mod_x = 3 elif event.key == pygame.K_LEFT: mod_x = 3 elif event.key == pygame.K_LEFT: mod_x = 3 elif event.key == pygame.K_LEFT: mod_x = 3 else: mod_x = mod_y = 0 if event.type == pygame.QUIT: Game = False game_loop() pygame
player((10,100)).