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 trialTrenton Spears
Python Development Techdegree Graduate 16,969 PointsStuck again.
Create another method called check_if_hungry that also only takes self. Inside of the method, if the is_hungry attribute is True, then call the eat method.
class Panda:
species = 'Ailuropoda melanoleuca'
food = 'bamboo'
name = 'Bao Bao'
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}.'
def check_if_hungry(self):
if self.is_hungry:
return f'{self.name} eats {self.food}.'
2 Answers
boi
14,242 PointsYou're word away from completing the challenge. Read the instructions carefully " if the is_hungry attribute is True, then CALL THE EAT METHOD".
The challenge requires you to Call the eat()
method.
class Panda:
species = 'Ailuropoda melanoleuca'
food = 'bamboo'
name = 'Bao Bao'
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}.'
def check_if_hungry(self):
if self.is_hungry:
return f'{self.name} eats {self.food}.' 👈#Here.
Evelyn Meza
4,226 Pointsi put in exactly how both codes look ad keep getting:
AssertionError: 'self.eat()' not found in 'class Panda:\n species = \'Ailuropoda melanoleuca\'\n food = \'bamboo\'\n\n def init(self):\n self.is_hungry = True\n def init(self, name, age):\n self.name = name\n self.age = age\n def eat(self):\n self.is_hungry = False\n return f"{self.name} eats {self.food}."\n def check_if_hungry(self):\n if self.is_hungry == True:\n return f\'{self.name} eats {self.food}.\'' : Inside of the if statement, call the eat method using self.
Trenton Spears
Data Analysis Techdegree Student 42 PointsHey Evelyn Meza, I apologize for such late response time, but I'll just forward you to this community discussion covering the same section. You might find your answer and a solid understanding there. If you're still having trouble after that, then I'll see what I can do. Take it easy and keep up the great work!
Community Discussion:
Your Willy Wonka golden ticket is HERE
Trenton Spears
Python Development Techdegree Graduate 16,969 PointsTrenton Spears
Python Development Techdegree Graduate 16,969 PointsThank you much again!!