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 trial

Python Basic Object-Oriented Python Welcome to OOP Creating a Panda Class

init method missing one positional argument "is_hungry"...can't understand why

Hello, i think it's a dumb quesiton

panda.py
class Panda():
    species = "Ailuropoda melanoleuca"
    food = "bamboo"
    def __init__(self, is_hungry):
        self.is_hungry = True

1 Answer

Brandon White
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Full Stack JavaScript Techdegree Graduate 35,771 Points

Hi Francesco,

That's a confusing error. But if you think about the code that's being used to test your code it makes a bit more sense.

So here's what's going on. The challenge asks that the init method only take the self argument. But you've added a parameter for is_hungry.

The way the test code evaluates your code to see if it's accurate is by running your program, and creating an object from the Panda class.

So behind the scenes it's doing something like this:

from panda import Panda

panda_bear = Panda()

print(panda_bear)

The test isn't passing an argument into Panda(), but you're requiring an is_hungry argument. So that's where the "missing one positional argument is_hungry" comes from. The test (or user if that makes it easier to follow) is missing the is_hungry argument. And that error is being passed on to you.

Just remove the is_hungry parameter and you'll pass the challenge.