Hi, so I want to calculate the factorial of a number. I thought best way is to take the number in a loop, and every loop reduce it by 1 and put those numbers in a list.
After that multiply the components of the list with
But its giving me this error:
Oops, try again. factorial(1) returned 0 instead of 1
def factorial(x): mult = [x] for i in range(x): mult.append(i) x = x - 1 fact = reduce(lambda b, a: a*b, mult) return fact
I don't understand, please can someone explain this to me