Not sure what is wrong with the Python code below. Will appreciate any help. I have looked into here and here, but could not solve my issue.
Code:
class myClass:
def factorial(n,self):
if n == 1:
return 1
else:
return n * self.factorial(n-1)
obj = myClass()
obj.factorial(3)
Error
Traceback (most recent call last):
File "a.py", line 9, in <module>
obj.factorial(3)
File "a.py", line 6, in factorial
return n * self.factorial(n-1)
AttributeError: 'int' object has no attribute 'factorial'