School Catalogue Step 14 Issues

Hi All,
I’m having trouble with this step in the School Catalogue Project. I’m pretty fuzzy on classes in general, but every time I run my code I get an error that I don’t understand. I would greatly appreciate some help. Very new to these forums so let me know if I broke any conventions.

class School: def __init__(self, name, level, numberOfStudents): self.name = name self.level = level self.numberOfStudents = numberOfStudents def getName(self): return self.name def getLevel(self): return self.level def getNumberOfStudents(self): return self.numberOfStudents def setNumberOfStudents(self, value): self.numberOfStudents = value def __repr__(self): return "A " + str(self.level) + " school named " + self.name + " with " + str(self.numberOfStudents) + " students" School = School('Codecademy', 'high', 100) print(School) print(School.getName()) print(School.getLevel()) School.setNumberOfStudents(200) print(School.getNumberOfStudents()) class PrimarySchool(School): def __init__(self, name, numberOfStudents, pickupPolicy): super(name,"primary",numberOfStudents).__init__() self.pickupPolicy = pickupPolicy def getPickupPolicy(self): return self.pickupPolicy def __repr__(self): parentRepr = super().__repr__() return parentRepr + "The pickup policy is {pickupPolicy}".format(pickupPolicy = self.pickupPolicy) primary = PrimarySchool("Academy", 10, "True")

In School = School('Codecademy', 'high', 100)
You used School for both the class and for an object (an instance of that class), which causes a problem later.
You should use a different variable for the object (meaning a specific “school”) than for the name of the class.

Here’s a fix:

school1 = School('Codecademy', 'high', 100) # make a new School, call it school1
print(school1)
print(school1.getName())
print(school1.getLevel())
school1.setNumberOfStudents(200)
print(school1.getNumberOfStudents())

Also,
super(name,"primary",numberOfStudents).__init__()
should be
super().__init__(name,"primary",numberOfStudents)

3 Likes

have same problems(
hard to make noninvalid code.