For a given sequence of numbers [0, 1, 2, 3, 4, 5, 6] output a sequence of factorials: 0!, 1!, 2!, ..., n! The task must be solved in a functional style.
My problem is that if is present in the program, but it cannot be used. Also, do not use cycles. Tell me how to get rid of if-s. Here is my code. Thank you in advance.
from itertools import accumulate a = [0, 1, 2, 3, 4, 5, 6] a = map(lambda x: 1 if x == 0 else x, a) # [1, 1, 2, 3, 4, 5, 6] print(*accumulate(a, lambda x, y: x * y))