Hippo , sloth and ocelot


#1

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
hippo = Animal("Hippy", 10)
sloth = Animal("piggy" , 10)
ocelot = Animal("tommy" , 12)
hippo.description()
print hippo.health
print sloth.health
print ocelot.health

OUTPUT:
Hippy
10
good
good
good
None

BUT WHY IT DOESN'T GIVES THE OUTPUT AS FOLLOWING:
Hippy
Piggy
Tommy
10
10
12
good
good
good
None

WHY IT DOESN'T PRINT NAME AND AGE OF ALL THE ANIMALS??


#2

you only called the description() method on hippo, not the other animals


#3

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