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

"Bao Bao eats bamboo" != "Bao Bao eats bamboo"

What is wrong with my code? No where does it say I have to add the actual name and age but I did just in case, it still doesn't work.

(Below is the error message I get)

panda.py
class Panda:
    species = 'Ailuropoda melanoleuca'
    food = 'bamboo'
    name = "Bao Bao"
    age = 1

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

    def eat(self):
            self.is_hungry = False
            return f'{self.name} eats {self.food}'

F FAIL: test_results (main.TestFunctionDefinitionExecution) Traceback (most recent call last): File "", line 64, in test_results AssertionError: 'Bao Bao eats bamboo' != 'Bao Bao eats bamboo.'

Bao Bao eats bamboo Bao Bao eats bamboo. ? + : When I call the eat method, I don't get the correct message. Make sure to use the name attribute that is passed in to the instance.

1 Answer

here's the correct code. This thing just wants the user to add a period at the end of the returned string. A period at the end of the "Bao Bao eats bamboo." sentence. ugh...

class Panda:

species = 'Ailuropoda melanoleuca'

food = 'bamboo'

def __init__(self, name, age):

    self.is_hungry = True

    self.age = age

    self.name = name 


def eat(self):

    self.is_hungry = False

    return f'{self.name} eats {self.food}.'