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

Andy McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andy McDonald
Python Development Techdegree Graduate 13,801 Points

Dont know how to make an attribute to an __init__ method while only passing the self argument.

Problem asks: Create a class called Panda. Inside your class, create two class attributes. One called species set to ‘Ailuropoda melanoleuca’ and another called food set to ‘bamboo’. The best I can do: class Panda: species = 'Ailuropoda melanoleuca' food = 'bamboo'

def __init__(self, is_hungry=True):
    self.is_hungry = is_hungry

fat_panda = Panda()

Error says that 1 != 2. Can only pass the self argument. Pretty sure I have not been taught to do that yet...

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

    def __init__(self, is_hungry=True):
        self.is_hungry = is_hungry

fat_panda = Panda()

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

You are so close. The task does not ask for any __init___ parameters. It wants you to hard code the value to True So,

self.is_hungry = True

Now the extra parameter can be removed.

As for passing an argument to __init__, your syntax would be correct.

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