Introduction to classes


Traceback (most recent call last):
File "python", line 8, in
TypeError: init() takes exactly 2 arguments (3 given)

Replace this line with your code. 
class Animal(object):
    def __init__(self,name):


Okay okay i understood..:slight_smile:


I thought we have to pass the name of the object also..


You should pass the name, "Jeffrey".
You got the error message that you did because self was already passed to any Animal animal object.
The __init__ shows that you need the two arguments self and name. self is automatically passed, so you just need to pass "Jeffrey" to the zebra object.

It would look like

zebra = Animal("Jeffrey") #spacing doesn't really matter regarding equal signs.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.