School Catalogue Project, "TypeError: object() takes no parameters"

Hey everybody,

I’m currently stuck at the “School Catalogue” Project in the Python 3 Intermediate Course.
School Catalogue

I’ve only managed to make my way till the first Checkpoint and I always get a error message.

Here is the code I used to check my progress so that would be task 1 to 7

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, newNumberOfStudents):
    self.numberOfStudents = newNumberOfStudents

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

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

print(mySchool)

It always creates some kind of error message.
For example:

Traceback (most recent call last):
File “script.py”, line 19, in
mySchool = School(“Codecademy”, “high”, 100)
TypeError: object() takes no parameters

Has somebody an idea what my mistake could be?

Thanks in advance,
Louis

Hi.
It may just be a formatting thing on here, but do you have double underscores around init and repr.
i.e.

def __init__(self, ....)

It could be that python doesn’t recognise your init section, so assumes your class doesn’t take any parameters.

Hey

that was it, thank you!

1 Like