Reduce function fails with three parameters and runs fine with two parameters in python

前端 未结 0 1685
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 09:54
from functools import reduce
o = [20,30,100,60,80,90]

#1 
print(reduce((lambda x,y:x+y),o)) # returns 380
#2
print(reduce((lambda x,y,z:x+y+z),o)) # FAILS
#3
print(         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题