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

add two arguments to your class in the __init__ method

Using your Panda class, add two arguments to your class in the init method called name and age. Set the values inside of the init method using self.

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

2 Answers

Mel Rumsey
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Mel Rumsey
Treehouse Staff

Hi there. Tafadzwa Mandimika! You are super close!

You have an unnecessary comma after the age parameter. Once that is removed you should be able to move on to the next part.

Note: You may need to hit the restart button to clear any cached answers then type your answer in again.

Happy coding! :D

hie Mel Rumsey ,thank you for the response... ive done as you advised im getting this error : Bummer: AssertionError: Regex didn't match: 'self.is_hungry\s=\sTrue' not found in "class Panda:\n species = 'Ailuropoda melanoleuca'\n food = 'bamboo'\n def init(self, name, age):\n self.is_hungry= True\n self.name = name\n self.age = age" : The instance attribute should be set with self and equal to True.

Mel Rumsey
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Mel Rumsey
Treehouse Staff

Ah okay I see what the other issue is. Somehow the space got deleted from

self.is_hungry = True

and became:

self.is_hungry= True

Makes sure you have a space on both sides of the equal sign :)

that worked , thank you alot hey :)