9. They're Multiplying!


#1


My code works but gives me the error message "Oops, try again. Did you create an Animal() called sloth?"


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
    hippo = Animal("Jake" , 12)
    sloth = Animal("Kyle", 10)
    ocelot = Animal("Frank", 5)
        
    print hippo.health
    print sloth.health
    print ocelot.health


#2

creating instances (hippo = Animal("Jake" , 12))of an object should be after the object, not nested inside (remove the indent of the instance you are creating)


#3

Take out all indentations after (print self.age)


#4

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