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 trialKat Alicea de Leon
1,787 Points"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)
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
Kat Alicea de Leon
1,787 Pointshere'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}.'
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 Pointscomment changed to answer. Marked best answer.