I'm new to python classes and I heard that every method needs to have the "self" parameter. I didn't understand why and tried to make a method without the self parameter. I then made an instance of the class and used the method without any argument (because there's no parameters duh) and I got an error:
TypeError: sayHi() takes 0 positional arguments but 1 was given
I do not understand why this happens because I haven't give any argument to the method.
Here is the code:
class hooman:
def sayHi(self):
print("hi")
hooman1 = hooman()
hooman1.sayHi()
It would be appreciated if someone could also tell me why is the self parameter is needed.