They're Multiplying (What's wrong with my code?)


#1



https://www.codecademy.com/courses/python-intermediate-en-WL8e4/1/4?curriculum_id=4f89dab3d788890003000096#

Did you create an Animal() called sloth?

I did 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("Harry", 21)
        sloth = Animal("Sammy", 7)
        ocelot = Animal("Bobo", 16)
        description(hippo)
        print hippo.health
        print sloth.health
        print ocelot.health


#2

description is a function, it should be a method of animal

creating a class instance (sloth), should happen outside the class (so no indention at all)


#3

What do you mean by that?


#4

that your indention is off. Description is a function, it should be a method of animal class, but it isn't given it isn't properly indented

if you need more help, post an updated version of your code


#5

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