A Methodical Approach



Hello, I am getting console errors but am unsure how to resolve them. Can anyone provide guidance? Thanks!

Traceback (most recent call last):
File "python", line 1, in
File "python", line 12, in Animal
NameError: name 'Animal' is not defined

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():
        print self.name
        print self.age
    hippo = Animal("harry", 5)


Remove those lines from the class (take out the indentation).


Thanks--now I'm getting this:
Traceback (most recent call last):
File "python", line 14, in
TypeError: description() takes no arguments (1 given)

I'm unsure why it says I'm passing an argument--I didn't put anything between the parenthesis...


Your method cannot see the self object. It should be the parameter:

def description(self):


You're a genius--thank you!


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