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 Adding to our Panda

Challenge: Adding to our Panda

I get this error when running my code:

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.

I'm not sure what I'm missing here

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

panda = Panda('Bao Bao', '5')

2 Answers

Hi Sam Cerwinske this challenge is super particular. 'Bao Bao eats bamboo' != 'Bao Bao eats bamboo.' The only difference is the missing period. You were super close, in your return statement add a period to the end of the sentence and you can remove the panda instance and it should work for you. I got hung up on this one too. That punctuation can get us sometimes! ;) Hang in there!

oh thank you so much! thats a silly error haha

I am a bit confused with the statements self.name and especially the self.food

initially I had:

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

Could someone please explain why we have to add self. before food?

Thank you