9/18 health member?


#1

class Animal(object):
"""Makes cute animals."""
is_alive = True
def init(self, name, age, health):
self.name = name
self.age = age
self.health = health
def description(self):
print self.name
print self.age
print self.health
hippo = Animal("Henry",10 ,"good")
sloth = Animal("Bob" ,11 , "good")
ocelot = Animal("Dan" ,14 ,"good")
hippo.description()
sloth.description()
ocelot.description()


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


#2

If we're gonna read that you'll need to fix the formatting of your post


#3

Hi mate, I am certainly not an expert, but I think you have written 'health' in as an instance variable ie init(self, name, age, health). I passed the exercise including it as a member variable ie health = "good" underneath is_alive = True, before you get into the def__init__() bit. That way you don't need to edit the def__init__ () and def description methods further down


#4

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

sloth = Animal("Pi", 4)
sloth.description()
print sloth.health

ocelot = Animal("Tingle", 20)
ocelot.description()
print ocelot.health

hippo = Animal("larry", 3)
hippo.description()
print hippo.health

this worked for me


#5

It seems that the more I try the more I need to learn. Sometimes I can't figure out the code and I have to look at other peoples code so I can move on. There are times when I have my moments(HURRAY FOR ME!) But at times they are few and far in between. I really need a mentor.