They're Multiplying- Intro to Classes Clarification


Hi All, the code doesn't really misbehave, I would like a clarification on the Hint.

The hint suggests I should print at the end. but my code works just fine. Have I misunderstood the exercise or is this just another way to do it ? please let me know.

I just added health to the description function, assuming this would make things easier to call at the end.

class Animal(object):
    """Makes cute animals."""
    is_alive = True
    health = "good"
    def __init__(self, name, age): = name
        self.age = age
    # Add your method here!
    def description(self):
        print self.age
hippo = Animal("John Snow", 25)
sloth = Animal("John Cena", 16)
ocelot = Animal("Jason Statham", 53)
print hippo.description()
print sloth.description()
print ocelot.description()


I believe by printing out the description of hippo that includes its health, you did what they wanted and therefore to conclude this might be another method to do the excersise. Although I would prefer to use because it is much simpler and easier. That is because I am not sure if the code would have worked if you did not define health in description in the first place.
Happy Coding


The way your code is written the health of the hippo is included in the instructions. Had you only added the health variable to line 4 as the instructions lay out, you would have had to call print separately in order to print that particular line. So the hint is more for people who don't put 2 & 2 together to add the print line to the description() function.


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