Reduce function with three parameters

前端 未结 3 1154
谎友^
谎友^ 2020-12-10 01:51

How does reduce function work in python3 with three parameters instead of two. So, for two,

tup = (1,2,3)
reduce(lambda x, y: x+y, tup)
<         


        
3条回答
  •  囚心锁ツ
    2020-12-10 02:21

    reduce optional third argument :

    >>> import functools
    >>> test = []
    >>> functools.reduce((lambda x,y: x+y), test, "testing")
    

提交回复
热议问题