Python 3 Intermediate - School Catalogue Project


I’m running into an error with the Python 3 Intermediate School Catalogue Project that I’ve been unable to resolve. Specifically, when I call the repr for the School class, the string is returned successfully but then followed by a string error. Probably some silly mistake but I’ve been unable to figure it out. My code and an example of the call and error are below. Any suggestions would be appreciated!



My code:


class School:
def init(self, name, level, numberOfStudents): = name
self.level = level
self.numberOfStudents = numberOfStudents

define getters for certain properties

def get_name(self):

def get_level(self):
return self.level

def get_numberOfStudents(self):
return self.numberOfStudents

define setter for numberOfStudents

def set_numberOfStudents(self,newNumberOfStudents):
self.numberOfStudents = newNumberOfStudents

create a repr() method to print School relevant info:

def repr(self):
print(‘A {level} school named {name} with {numberOfStudents} students’.format(level = self.level, name =, numberOfStudents = self.numberOfStudents))

class PrimarySchool(School): # inherits from School
def init(self, name, numberOfStudents, pickupPolicy):
super().init(name, ‘primary’, numberOfStudents)
self.pickupPolicy = pickupPolicy

def get_pickupPolicy(self):
return self.pickupPolicy

def repr(self):
parentRepr = super().repr() # override parent repr method
print(parentRepr + “The pickup policy is {pickupPolicy}”.format(pickupPolicy = self.pickupPolicy))

class HighSchool(School): # inherits from School
def init(self, name, numberOfStudents, sportsTeams):
self.sportsTeams = sportsTeams

def get_sportsTeams(self):
return self.sportsTeams

def repr(self):


create school object and verify

mySchool = School(“Codecademy”,“high”,100)
print(mySchool) # prints repr stuff - not sure why error?

My error:

A high school named Codecademy with 100 students
Traceback (most recent call last):
File “”, line 57, in
print(mySchool) # prints repr stuff - not sure why error after prints!
TypeError: str returned non-string (type NoneType)

Hello there!
repr is supposed to return a string which it’ll then print out.
You’re manually printing the string within the function but not returning anything.
It might not have given out an error for the school class, but in the primary class, parentRepr is getting an undefined value when you call super(), hence the error message.

Hope that helps


Thank you for the advice, that totally makes sense. Code now working perfectly!