编写一个prod()函数,可以接受一个list并利用reduce()求积。

from functools import reduce
def prod(x,y):
 return x * y
L = reduce(prod,[3,5,7,9])
print(L)

打印结果如下: