Dominic Sen Dominic Sen - 1 year ago 67
Python Question

Specific subclass in python gives syntax error

class Item():
def __init__(self, name, cost, image): = name
self.cost = cost
self.image = image

class Weapon(Item):
def __init__(self, name, cost, image, damage):
self.damage = damage
super().__init__(name, cost, image)

class W_S(Weapon):
def __init__(self):
super().__init__(name="Wooden Sword", cost = 50, damage = 3, image = pygame.image.load('wood_sword.png')

class S_S(Weapon): #Syntax error here
def __init__(self):
super().__init__(name="Stone Sword", cost = 75, damage = 6, image = pygame.image.load('stone_sword.png')

class I_S(Weapon):
def __init__(self):
super().__init__(name="Iron Sword", cost = 100, damage = 9, image = pygame.image.load('iron_sword.png')

I am trying to create a basic weapons subclass for S_S(stone sword) and I get an error that highlights the word
class S_S(Weapon):

Answer Source

You are missing a closing paren at the end of ALL the lines that call super().