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
MOD
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

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.