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)
I get this one. This would just sum up all the elements in tup. However, if you give reduce function three parameters like this below,
tup = (1,2,3)
reduce(lambda x, y: x+y, tup, 6)
this would give you a value of 12.
I checked up on the documentation for python3 and it says the third argument is an initializer. That said, then what is the default initializer if the third argument is not inserted?