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 trialCam S
8,440 Pointswhat am i doing wrong here? OOP challenge
not sure what to do. i have tried assigning a default to name but then it says 'non-default comes after default'. switched the order and it says it has to be self, name, and age. tried setting a class attribute for name but that also did not work. any advice is appreciated, 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 '{} eats {}.'.format(name, food)
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsHey Cam S, youβre close. To access the instance attribute use self.name
and self.food
Post back if you need more help. Good luck!!!
Cam S
8,440 PointsCam S
8,440 Pointsahhh wow, thanks so much for both of your responses. was able to solve the challenges. appreciate you!