reduce

# __author: "ZXYang"
# date: 2020/12/10
from functools import reduce

nums = [1, 2, 3, 4, 5]

print(reduce(lambda x, y: x + y, nums, 100))
print(reduce(lambda x, y: x + y, nums))

print(reduce(lambda x, y: x * y, nums, 10))
print(reduce(lambda x, y: x * y, nums))
posted @ 2020-12-10 22:07  zxy_ang  阅读(117)  评论(0)    收藏  举报