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 trialAnthony Welsh
4,025 PointsHi, can anyone advise where i'm going wrong in my code for part 2 of this question?
Thanks
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('{self.name} eats {food}.')
1 Answer
boi
14,242 PointsYou have three errors, two are syntax, the third is a regex unmatched error (which is not really an error). Focus on the two syntax errors.
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('{self.name} eats {food}.')👈# All three errors are here.
Your format string syntax is wrong, and food
is called wrong here, since its in a class
....I think you know how to call it.
As for the third error just remove the brackets ()
from the return statement and give a space after return
like this;
return '{self.name} eats {food}.'
If you need help, msg me on this post.
Anthony Welsh
4,025 PointsAnthony Welsh
4,025 PointsThanks chief!