19/9 whats wrong with this code?


#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
sloth = Animal("sloth", 4)

print sloth.name,sloth.health

ocelot = Animal("Tingle", 20)

print ocelot.name,ocelot.health

hippo = Animal("larry", 3)

print hippo.name,hippo.health

after executing this code its showing following error:
Did you create an Animal() called sloth?


#2

Your class has improper indentation, it should look like this.

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

In some other languages you could get away with improper indentation, although that is discouraged obviously, but indentation is an important part of Python.


#3

Thanks for your help. got the solution to the issue.