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 Creating a Panda Class

I don't think this is covered in the previous video.

class Panda:
    species = 'Ailuropoda melanoleuca'
    food = 'bamboo'
    def __init__(self,is_hungry=True):
        self.is_hungry = is_hungry

Getting an error stating that I'm suppose to have only one attribute called self.
So how do you set is_hungry=True? Above code is all i got from the previous video.

panda.py
# insert your code here
class Panda:
    species = 'Ailuropoda melanoleuca'
    food = 'bamboo'

2 Answers

Steven Parker
Steven Parker
217,627 Points

The instructions say that your method "should only take the self argument", but this code gives it two arguments instead.

Also, the Markdown code to indicate formatted lines is 3 accents (```), not apostrophes (''').

Steven,

Thanks for the 3 accents.
I figured it out. I forgot the importance of the 'pass' keyword within the init method. This allowed me to only take the self argument without getting unwanted errors. The previous video didn't mention this. So luckily I still had notes from past videos on 'pass'.

Shawn

Steven Parker
Steven Parker
217,627 Points

I'm not sure why you'd need "pass" here. If I just take your original code and remove the 2nd argument, and then change the assignment to use "True", it passes the challenge.

Steven,

You are correct. I must of misspelled something. I revisited the test and it work without pass.

Shawn

class Panda:
    species = 'Ailuropoda melanoleuca'
    food = 'bamboo'
    def __init__(self):
        self.is_hungry = True