School Catalogue project - Python 3 Intermediate course

Hello everyone!

I want help with my Python3 intermediate course School Catalogue project.
Here it is: Learn Intermediate Python 3 | Codecademy

It throws this error:
Traceback (most recent call last):
File “”, line 59, in
TypeError: repr() missing 2 required positional arguments: ‘name’ and ‘numberOfStudents’

Please help, what am I doing wrong?

It’s difficult to tell b/c you’ve not provided any code. So, please provide your (formatted) code that you’ve written so far.

Please follow this guide when posting:

Here’s my code.

class School():

  def __init__(self, name, level, numberOfStudents): = name,
    self.level = level
    self.numberOfStudents = numberOfStudents

  def getName(self):

  def getLevel(self):
    return self.level

  def getNumberOfStudents(self):
    return self.numberOfStudents

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

  def __repr__(level, name, numberOfStudents):
    print("A {} school named {} with {} students".format(self.level,, self.numberOfStudents))

a = School("Codecademy", "high", 100)

class PrimarySchool(School):
  def __init__(self, name, numberOfStudents, pickupPolicy, level = "primary"):
    super().__init__(name, "primary", numberOfStudents)
    self.pickupPolicy = pickupPolicy

  def getPickupPolicy(self):
    return self.pickupPolicy

  def __repr__(self, name, numberOfStudents):
    parentRepr = super().__repr__(name, numberOfStudents)
    return parentRepr + "The pickup policy is {}".format(pickupPolicy = self.pickupPolicy)

b = PrimarySchool("Codecademy", 300, "Pickup Allowed")

class HighSchool(School):
  def __init__(self, name, level, numberOfStudents, sportsTeams = []):
    super().__init__(name, "high", numberOfStudents)
    self.sportsTeams = sportsTeams

  def getSportsTeams(self):
    return self.sportsTeams

  def __repr(sportsTeams):
    parent = super().__repr__()
    return parent + f" information of our sport Team {', '.join(self.sportsTeams)}"

c = HighSchool("Codecademy High", 500, ["Tennis", "Basketball"])

def __repr__(level, name, numberOfStudents):
should be
def __repr__(self):
You’re to create a method (that requires zero argument when you call it),
so self should be the only parameter for the function.

1 Like

Okay, now that I have fixed that I get a new type of error.

Traceback (most recent call last):
File “”, line 59, in
TypeError: str returned non-string (type NoneType)

yes, the __repr__ function should return a string, not print it.

(change the print to return)

1 Like