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 trialSam Cerwinske
Courses Plus Student 2,876 PointsChallenge: 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
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
Mel Rumsey
Treehouse ModeratorHi 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!
Xavier van de Par
2,231 PointsI 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
Sam Cerwinske
Courses Plus Student 2,876 PointsSam Cerwinske
Courses Plus Student 2,876 Pointsoh thank you so much! thats a silly error haha