Intermediate Python School Catalogue (inheritance)

Hi, everyone! How are you all?
I hope everyone is fine!
I´m getting trouble working on the School Catalogue Project. I´m missing something and the properties are not working as they should?
Can anyone look at my code and help me, please?
The problem is about inheritance. I put comments on the code to guide through it.

School class works fine, but PrimarySchool e HighSchool classes don´t. I think the problem is when I use super()int() .

https://www.codecademy.com/workspaces/61fa995a8f6c970a7a073114

class School: def __init__(self, name, level, numberOfStudent): self.name = name self.level = level self.numberOfStudent = numberOfStudent def get_name(self): return self.name def get_level(self): return self.level def get_numberOfStudents(self): return self.numberOfStudent def set_numberOfStudents(self, new_amount): self.numberOfStudents = new_amount def __repr__(self): return f"A {self.level} school name {self.name} with {self.numberOfStudent} students." class PrimarySchool(School): def __init__(self, name, numberOfStudent, pickuppolicy): super().__init__(name, 'primary', numberOfStudent) self.pickuppolicy = pickuppolicy def get_policy(self): return self.pickuppolicy def __repr__(self): parentRepr = super().__repr__() return parentRepr + "The pickup polity is {pickupPolicy}".format(pickupPolicy = self.pickuppolicy) mySchool = School("Codecademy", "high", 100) print(mySchool) print(mySchool.get_name()) print(mySchool.get_level()) mySchool.set_numberOfStudents(200) print(mySchool.get_numberOfStudents()) print('\n') testSchool = PrimarySchool("Codecademy", 300, "Pickup Allowed") print(testSchool.get_policy()) print(testSchool) print('\n') class HighSchool(School): def __init__(self, name, numberOfStudent, sportsTeams): super().__init__(name, 'High', numberOfStudent) self.sportsTeams = sportsTeams def getSportsTeams(self): return self.sportsTeams def __repr__(self): parent = super().__repr__() return parent + f" information of our sport Team {self.sportsTeams}" c = HighSchool("Codecademy High", 500, ["Tennis", "Basketball"]) print(c)

Your code (codebyte) on the forums seems to run just fine. The code in the workspace has some unfortunate typos that would need to be fixed up.

Main issue if you can't find it

Your method unfortunately reads __int__ instead of __init__ (missing i) so you never override the parent’s __init__ (that issue might be duplicated). There were a couple of other typos in there but the __init__ one is the sneakiest since it runs but just doesn’t do what you want.

OMG! Thank you very very much!

I correct the constructor and now it seems to work fine. I look at it for so long and I didn´t notice that!

Thank you!!!

1 Like