When I am trying to find factorial using below code, it is working for all numbers except '0'. When I give the input as 0, below error is displayed. Can some one help me to understand and fix the error
from functools import reduce
n = int(input())
fact = lambda a, b: a*b if (n>=1) else 1
reduce(fact, range(1,n+1))
Expected result: When input is given as '0' 1 should be displayed as output
Actual result: Below error is displayed
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-124-52f472210976> in <module>
3
4 fact = lambda a, b: a*b if (n>=1) else 1
----> 5 reduce(fact, range(1,n+1))
6
TypeError: reduce() of empty sequence with no initial value