#saying it takes 3 positional arguments where 4 given
12 messages · Page 1 of 1 (latest)
game_1 = Game(2025, 'Grand Theft Auto VI', 'London')
Show the full error message
the code for my class is:
class Game:
def __init__(year, name, city):
self.year = year
self.name = name
self.city = city
def __repr__(self):
return "game('{}', '{}', '{}')".format(self.year, self.name, self.city)
You're missing the self arg on the __init__ function
wdym?
You see __repr__? It has a self. You need that as the first arg to __init__ as well. It's required for functions in a class.
def __init__ (self, year, name, city): is how it should be