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

Bryan Ziel
Bryan Ziel
1,533 Points

This code challenge test is wrong

This code challenge keeps failing for me even though it runs correctly in workspace. I have to instantiate the class in the workspace, but the instructions do not say to do that. The test is failing saying it is not finding the proper return string.

panda.py
class Panda:
    species = 'Ailuropoda melanoleuca'
    food = 'bamboo'

    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}.')

2 Answers

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 26,896 Points

Check the hint at the end of the answer ;-)

Sorry you are feeling frustrated. More than a few times I felt frustrated and angry at the challenge grader because it didn't appear to work.

You shouldn't have to instantiate the object because the unit test does that. Also note that the challenge grader is a stupid automaton, so it didn't accept my answer the first time because I omitted the '.' character at the end. ;-)

Hint: remove the parenthesis on the return value. That should remove one of your difficulties.

Bryan Ziel
Bryan Ziel
1,533 Points

Ah, thank you for the hint, I have now gotten past that challenge. It would be nice if the grader actually passed based on what was returned, not just a regex matching a text pattern.

Beyond that I still think this question should be reworded. It says the string would return "Bao Bao eats bamboo" but the code does not set name="Bao Bao" anywhere, so that was another very confusing part of the challenge. Maybe add an additional instruction to instantiate the class setting name="Bao Bao".