They're multiplying -


#1



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

Oops, try again. Make sure to give your Animal class a health member variable.

Is health not a member variable in my code ?


class Animal(object):
    """Makes cute animals."""
    is_alive = True
    health = "good"
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def description(self):
        print self.name
        print self.age
        print self.health
    hippo = Animal("hippo",12)
    sloth = Animal("geraldine the great",7)
    ocelot = Animal("Catfish",9)
    hippo.description()
    
    print hippo.health
    print sloth.health
    print ocelot.health


#2

Indentation is very important in python,Make sure that last 8 lines of code are on 0-indentation.


#3

health is a member variable, but the problem are your class instance (hippo, sloth, ocelot) they should be created outside/after the class

like @greentreemee says, indention is the key here


#4

sorted - I see my mistake now

Thank you both!


#5

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