usage of reduce
Fredrik Lundh
fredrik at pythonware.com
Tue May 8 02:51:31 EDT 2001
SC Zhong wrote:
> I am using version 1.5.2
> would somebody tell me why the following does not work.
>
> >>> z
> [(1,5),(2,6),(3,7)]
>
> >>> reduce(lambda x,y: x[1]+y[1], z)
hint: what does the lambda expression return? does the
return value support element access?
(reduce calls the function on the first and second element
in your sequence, and then on the resulting value and the
third element)
Cheers /F
More information about the Python-list
mailing list