我正在尝试在 python 中减少并在期望其他值时得到 0:
In [1]: from functools import reduce
In [2]: reduce( (lambda x, y: x * y), [1, 2, 3, 4] )
Out[2]: 24
In [3]: def multiply(x, y): return x * y
In [4]: reduce( multiply, [1, 2, 3, 4] )
Out[4]: 24
In [5]: reduce( multiply, range(5) )
Out[5]: 0
In [6]: reduce( multiply, list(range(5)) )
Out[6]: 0
[...]
In [11]: L = list(range(5))
In [12]: L
Out[12]: [0, 1, 2, 3, 4]
In [13]: reduce(multiply, L)
Out[13]: 0
为什么我在不输入文字列表时得到 0?如何减少任意列表?我错过了什么?