They're Multiplying!- 9


#1



https://www.codecademy.com/en/courses/python-intermediate-en-WL8e4/1/4?curriculum_id=4f89dab3d788890003000096#


Traceback (most recent call last):
File "python", line 16, in
AttributeError: 'str' object has no attribute 'health'

Oops, try again. Did you create an Animal() called sloth?


It should be printing out the health of each animal.


class Animal(object):
    """Makes cute animals."""
    is_alive = True
    health = "good"
    def __init__(self, name, age):
        self.name = name
        self.age = age
    # Add your method here!
    def description(self):
        print self.name
        print self.age
Animal('hippo', 893)
Animal('sloth', 2)
Animal('ocelot', 5)

print 'hippo'.health
print 'sloth'.health
print 'ocelot'.health


#2

you should store your instances in variables


#3

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