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

Ashish Anand
Ashish Anand
1,552 Points

Even after making a class called Panda with two attributes the output throws an error saying that self is not needed.

As you can see from the code I have created a class called Panda with two attributes called species and food, but the error says that self is not needed for instantiating an object of the class Panda.

class Panda:
    species=Ailuropoda melanoleuca

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 67,736 Points

Hey Ashish Anand, The "self" error is part of a larger generic error message and does not apply to your code.

The real error is plainly stated before this. The species and food are not defined because the assigned string values are not within quotation marks. This leads to a syntax error, so the entire code is non-functioning.

Remember to a space is expected before and after an '"=** sign.

Post back if you need more help. Good luck!!

Ashish Anand
Ashish Anand
1,552 Points

Hi Chris,

Your right! I changed the variable assignment part with "" and with proper spacing. It worked!!