Alex Alex - 1 month ago 9
Python Question

Strange "Invalid Syntax" error

This is some of the code for my Pygame. I can't figure out what's wrong here:

class Aqua(object):
def __init__(self):
self.surf = pygame.image.load("Aqua.png").convert_alpha()
self.here = True
self.rect = pygame.Rect(240,55,32,32)

"""skipped some unrelated stuff"""

class Game(object):
def __init__(self):

"""skipped some unrelated stuff"""

self.aqua = Aqua()

"""skipped some unrelated stuff"""

def draw(self):
self.screen.blit(self.floor.floor_surf, (0,0))
for wall in self.walls:
self.screen.blit(wall.surf, wall.rect)
if self.lead.here:
self.screen.blit(self.lead.surf, (16,150))
if self.arsenic.here:
self.screen.blit(self.arsenic.surf, (304,150))

self.screen.blit(self.player.surf, self.player.rect, pygame.Rect(self.player.frame*32, self.player.dir*64, 32, 64))
self.screen.blit(self.table.surf, (0,0))
self.screen.blit(self.table.surf, (0,64))
self.screen.blit(self.table.surf, (192,64))
self.screen.blit(self.table.surf, (256,64))
self.screen.blit(self.table.surf, (320,64))
self.screen.blit(self.table.surf, (192,128))
self.screen.blit(self.table.surf, (00,192))
self.screen.blit(self.table.surf, (192,192))
self.screen.blit(self.table.surf, (00,256))
self.screen.blit(self.table.surf, (576,160))
self.screen.blit(self.table.surf, (576,224))

if self.mercury.here:
self.screen.blit(self.mercury.surf, (336,64))
if self.sulfur.here:
self.screen.blit(self.sulfur.surf, (32,289)
if self.aqua.here: #this is the line it doesn't like.
self.screen.blit(self.aqua.surf, (240,55))


when I try to run it, it refers to that second-to-last line, points to the word "here", and says "invalid syntax". Why?

sth sth
Answer

You are missing a closing parenthesis on the previous line.

It should be:

if self.sulfur.here:
    self.screen.blit(self.sulfur.surf, (32,289)) # add the second parenthesis
Comments