TypeError: Person() takes no arguments

Viewed 26540

I am new to python and trying to create class.when running this code every time getting error TypeError: Person() takes no arguments. I don't know why arguments not passing to class

class Person:
    def _init_(self,name,age):
        self.name=name
        self.age=age
    def myfun(self):
        print("my name is"+self.name)
        print("my age is"+self.age)

p1=Person("John",29)
p1.myfun()
2 Answers

The constructor must be named __init__, not _init_.

Related