#sample solution
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 "My name is %s." % (self.name)
print "I'm %s years old." % (self.age)
sloth = Animal("Jim",30)
ocelot = Animal("Pam",29)
hippo = Animal("Dwight",34)
print sloth.health
print ocelot.health
print hippo.health
You are missing hippos creation and health to this solution.
ReplyDeleteThanks. Updated the code.
Deleteclass Animal(object):
ReplyDelete"""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("babu",3)
print hippo.description()
print hippo.health
sloth = Animal("sam",6)
print sloth.health
ocelot = Animal("ram",23)
print ocelot.health
for this code i am getting the error
"Oops, try again! Did you create an Animal() called sloth?"
can someone help me? thanks in advance
Hello Vijaiya,
DeleteJust checked your code and it works. Just make sure you have proper indentation.
https://gist.github.com/nathanweis/7192730