I am new to Python. I was trying to define and run a simple function in a class.
Can anybody please tell me what’s wrong in my code:
class A : def m1(name,age,address) : print('Name -->',name) print('Age -->',age) print('Address -->',address) >>> a = A() >>> a.m1('X',12,'XXXX') Traceback (most recent call last): File '<pyshell#22>', line 1, in <module> a.m1('X',12,'XXXX')
I am getting below error
TypeError: m1() takes exactly 3 positional arguments (4 given)
Instance methods take instance as first argument:
You can also use @staticmethod decorator to create static function: