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 trialFrancesco Gambardella
2,094 PointsTypeError: __init__() missing 2 required positional arguments: 'name' and 'age'
The task is creating a method that return "Bao Bao eats Bamboo" and I got an error on the initsection which was a previous task that i thought to pass successfully. Thanks in advance for the help
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"{name} eats {food}")
panda_one = Panda()
print(panda_one.eat("Bao Bao"))
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou are close. The errors are in the return
line.
- return is not a function. remove parens
- f-string needs to reference the instance attributes. add “
self.
” - f-string needs missing period “.”
Plus,
- last two lines throw off checker. remove “panda_one” assignment and print statement
Post back if you need more help. Good luck!!!