class abc:
def yo(var):
a=var
print(a)
x=abc().yo(5)
Output:
Traceback (most recent call last):
File "main.py", line 5, in
x=abc().yo(5)
TypeError: yo() takes 1 positional argument but 2 were given
class abc:
def yo(self,var):
self.a=var
print(self.a)
x=abc().yo(5)
Output: 5
it's working till i use the self keyword i mean can we call a function without using self parameter in it why it says yo() takes 1 arguments and is given 2 when we exclude self?