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

error: Your init method should be declared with `def` and take only self as an argument.

I tried a couple of different codes and they all fail with this error message

def init(self):

should be right... right? or do i have to do this

def init(self, is_hungry=True):
# insert your code here
class Panda:
    species = "Ailuropoda melanoleuca"
    food = "bamboo"
    is_hungry = True

def __init__ (self):


1 Answer

Hi Jan!

A couple of issues:

1) the init method should be a class method, so it should be indented (4 spaces) to line up with the species and food class attributes

2) is_hungry should be set only inside the init method

3) eliminate the space between init and (self):

This passes:

# insert your code here
class Panda:
    species = "Ailuropoda melanoleuca" # indented 4 spaces
    food = "bamboo" # indented 4 spaces

    def __init__(self): # indented 4 spaces
        self.is_hungry = True # indented 8 spaces

Make sure to always indent in multiples of 4 spaces (4/8/12/16/20/etc. - don't use tabs)

I hope that helps.

Stay safe and happy coding!