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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![taliarosen](https://secure.gravatar.com/avatar/a5d16fec61bff0e89ac89c4643394c0c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
taliarosen
2,492 PointsAssertion Error
I'm getting an error that what is returned is not correct for the objective but I don't see any issues.
The objective is: Create a method called eat. It should only take self as an argument. Inside of the method, set the is_hungry attribute to False, since the Panda will no longer be hungry when it eats. Also, return a string that says 'Bao Bao eats bamboo.' where 'Bao Bao' is the name attribute and 'bamboo' is the food attribute.
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_one = Panda('Bao Bao', '12')
panda_one.eat()
2 Answers
![Thomas Fildes](https://secure.gravatar.com/avatar/da6ddb34e3d2a029a7df69198853f56e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Thomas Fildes
22,687 PointsHi,
This was puzzling me for a long time. I have looked at your code and can see that you have put parenthesis in your return function which is not required. The below code worked for me:
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}.'
panda2 = Panda('Bao Bao', 12)
panda2.eat()
Hope this helps. Happy coding!
Tom
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsIt's not necessary to put parentheses around the formatted string, and they don't cause a problem in themselves, but the challenge is expecting a space after the return
keyword as you would need if you didn't have the parentheses.
Also, the challenge only asks you to add code to the class. You don't need to add any code to create an object instance or call any of the methods.
![Thomas Fildes](https://secure.gravatar.com/avatar/da6ddb34e3d2a029a7df69198853f56e?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Thomas Fildes
22,687 PointsHi Steven,
Sorry for not getting back to you sooner. Yes you are correct the two bottom lines aren't required to pass the challenge. I just used them as part of my code to pass through it. At least a solution has been found to assist with this and thank you for your help and assistance with it.
Steven Parker
230,688 PointsSteven Parker
230,688 PointsDid you see my answer from yesterday?
Those 2 lines at the bottom might not break the challenge, but they still shouldn't be there!
I point this out because in some other challenges, doing "extra" stuff can indeed cause a failure.