Why do you have to put parentheses at the end?


A Methodical Approach

it behaves fine. I just have a question.

when I want to print the hippo's description, why do i have to put parentheses at the end? Is this just a syntax thing? When i dont put the parenthese in, code academy accepts it but I get a weird message in the editor.

class Animal(object):
    """Makes cute animals."""
    is_alive = True
    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("Pip", 9)
print hippo.description()


Furthermore, for the next exercise: "They're Multiplying", when you want to print the health of the animals you write:

print hippo.health
print sloth.health
print ocelot.health

and there are no parentheses at the end!!!

I am so confused about this parentheses thing!


hippo.description is a function, so that is why you need the parentheses. hippo.health is a variable.


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