Код: Выделить всё
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)
Код: Выделить всё
AttributeError: module 'Answer' has no attribute 'factorial'"
Подробнее здесь: https://stackoverflow.com/questions/798 ... tribute-fa
Мобильная версия