ARTICLE AD BOX
class Answer:
def __init__(self, n):
self.n = n
def factorial(self):
# n = self
if isinstance(self, str):
pass
else:
factVal = 1
print(self)
for i in range(int(self)):
factVal *= i + 1
return factVal
number = 5.5
result = Answer.factorial(number)
print("Result: ", result)
This code is working and returning what I expect but also returns "AttributeError: module 'Answer' has no attribute 'factorial'". I cant figure out why im getting this error. I am new to Python but have been writing code in Javascript for years.
