A Methodical Approach


#1



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


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)
    
    hippo.description()


#2

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


#3

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...


#4

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

def description(self):

#5

You're a genius--thank you!


#7

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