Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Basic Object-Oriented Python Welcome to OOP Adding to our Panda

Angel Miranda
Angel Miranda
2,433 Points

its throwing an assertion error but everything looks like it should be where its at.

panda.py
class Panda:
    species = 'Ailuropoda melanoleuca'
    food = 'bamboo'
    is_hungry = True

    def __init__(self, name, age):
        self.name = marty
        self.age = 45

1 Answer

Steven Parker
Steven Parker
216,810 Points

There's a couple of issues:

  • no variable named marty has been created, but you don't need it because...
  • the init should store the values that come in as the arguments instead of using literals
Angel Miranda
Angel Miranda
2,433 Points

so I have to write functions for each value? I tried writing self.name, self.name(), self.name(name), self.name = name, and self.name = "name" within the function. I also tried writing name="name" within the parameters but it keeps throwing the same error.

Steven Parker
Steven Parker
216,810 Points

I'm not sure what you mean by "functions for each value", but the code above is very close. You just need name instead of marty. Then you need to make a similar fix for the age.

Also, don't change the part of the code that sets "is_hungry", just leave that as provided.

Angel Miranda
Angel Miranda
2,433 Points

I changed Marty to name and 45 to age but it still throws the same error.

Steven Parker
Steven Parker
216,810 Points

And did you also put the code that sets "is_hungry" back to how it was when the challenge started?