I’m working on the school catalog project in the Machine Learning/AI Engineer course.
I’m stuck on steps 15 and 16. Step 15 asks you to create a high school class inherited from the original school class. It then asks you to Create a constructor that accepts arguments for name
, numberOfStudents
, and sportsTeams
Step 16 asks you to test the code to make sure it works correctly. It says to create a High School
object and verify your new constructor, getter method, and __repr__()
method work as expected.
My code is below:
class HighSchool(School):
def init(self, numberOfStudents, sportsTeams):
super().init(name, ‘High’, numberOfStudents)
self.sportsTeams = sportsTeams
def get_sportsTeams(self):
return self.sportsTeams.append(list)
def repr(self):
sportFun = super().repr()
return sportFun + " The school’s sports are {sportsTeams}".format(sportsTeams = self.sportsTeams)
g = HighSchool(‘Dunbar’, 650, [‘Baseball’, ‘Rugby’])
print(g.getsportsTeams)
print(C)
I keep getting a message saying:
Traceback (most recent call last):
File “script.py”, line 45, in
g = HighSchool(‘Dunbar’, 650, [‘Baseball’, ‘Rugby’])
TypeError: init() takes 3 positional arguments but 4 were given
How do I get the function to take 4 positional arguments?
Thanks