Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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
229,732 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

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
229,732 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.

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

Steven Parker
Steven Parker
229,732 Points

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