6/18


#1

https://www.codecademy.com/courses/python-intermediate-en-WL8e4/1/1?curriculum_id=4f89dab3d788890003000096
class Animal(object):
"""Makes cute animals."""
# For initializing our instance objects
def init(self, name, age):
self.name = name
self.age = age
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
def init(self, name, age, is_hungry):
self.name = name
self.age = age
self.is_hungry = is_hungry

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

So, I tried to figure out what to do, but I haven't been able to figure it out so far, as I see nothing visibly wrong with line 13. I'm hoping that more experienced coders will try to help me figure this out.


#2

@the_tarn,
Try it with

class Animal(object):
    """Makes cute animals."""
    # For initializing our instance objects
    def __init__(self, name, age, hungry):
        self.name = name
        self.age = age
        self.is_hungry = 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

#3

Thank you, that worked.