6. More on _init()_ and self


#1

class Animal(object):
"""Makes cute animals."""

def init(self, name, age):
    self.name = name
    self.age = age
    self.is_hungry = is_hungry

zebra = Animal("Jeffrey", 2, True)
giraffe = Animal("Bruce", 1, False)
panda = Animal("Chad", 7, True)

print zebra.name, zebra.age, zebra.is_hungry
print giraffe.name, giraffe.age, giraffe.is_hungry
print panda.name, panda.age, panda.is_hungry

this is my code and my error says
"Traceback (most recent call last):
File "python", line 13, in
TypeError: init() takes exactly 3 arguments (4 given)"
and this
"Oops, try again. Did you add the is_hungry attribute to init()?"


#2

1) Make sure that your code is properly formatted in your post
2) init and __init__ are two different names, which one are they talking about?


#3

try this:
def init(self, name, age, is_hungry):


#4

double underscore before and after init __


#5

You don't need any of this all it is asking is to have this

def init(self, name, age):
self.name = name
self.age = age
self.is_hungry = is_hungry


#6

def init(self, name, age, is_hungry):
self.name = name
self.age = age
self.is_hungry = is_hungry
This is what the lesson is asking for


#7

try this

def init(self, name, age, is_hungey):
self.name = name
self.age = age
self.is_hungry = is_hungry

but before and after the init, put 2 underscores