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 trialEmily H
2,861 PointsI don't know what to do
Hi there, I already posted about this coding challenge, I'm just on the last part and kinda struggling on it. What do I do next? Am I doing something wrong?
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
name = 'Bao Bao'
food = 'bamboo'
return f'{self.name} eats {self.food}.'
def check_if_hungry (self):
if self.is_hungry = True:
1 Answer
Steven Parker
231,269 PointsA few hints:
- when testing equality, use the comparison operator ("==") instead of the assignment operator ("=")
- you never need to test for "True" anyway, you can just name the value (
if self.is_hungry:
) - you still need the 2nd part of the task — if the test passes, "then call the eat method"
- you don't need to create local variables for "food" and "name" in the eat method
Emily H
2,861 PointsEmily H
2,861 PointsGot it, thank you!