9. They're Multiplying!


#1

I keep getting an error that says “sloth isn’t an instance of the Animal class”

Here is 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
  def print_health(self):
      print self.health
hippo = Animal("Hippy", 2)
sloth = Animal("Speedster", 5)
ocelot = Animal("Zork", 3)
hippo = hippo.print_health()
sloth = sloth.print_health()
ocelot = ocelot.print_health()

#2

Hi @patelsoftworks,

These three statements assign None to hippo, sloth, and ocelot.

hippo = hippo.print_health()
sloth = sloth.print_health()
ocelot = ocelot.print_health()

They should not be assignment statements. To preserve the objects, you can just call the print_health method on each of the three objects without assigning the result to the objects.

However, the instructions actually want you to do it this way …

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

#3

I understand now, thank you so much!


#4