Wrong with class creation code

i don’t understand what is wrong below:

class Pet:

def init(self,input_name,input_age,input_breed,input_type,is_vegan=True):

 self.name=input_name

 self.age=input_age

 self.breed=input_breed

 self.type=input_type

 self.vegan=is_vegan

pet_one=Pet(“ammu”,10,“local”,“tiger”,True)

the aboce code is returning Traceback (most recent call last):
File “script.py”, line 12, in
pet_one=Pet(“ammu”,10,“local”,“tiger”,True)
TypeError: object() takes no parameters

can somebody clarify it

Hi,
does your init have two underscores each side ?
_ _ init _ _ (no spaces. they’re just there for clarity)

Your example looks like it might be just one, so it wouldn’t recognise it as the correct method.

hope that helps

thanks a lot… @pluginmaybe

1 Like