Pythonic way to sum n-th list element?
Fri Apr 18 22:28:58 CEST 2003
guy at obstruction-no-spam.com (Guy Middleton) writes:
> What is the most Pythonic way to sum the n-th element of a list of lists (or
> of tuples)?
> The obvious (to me) way is to use reduce, a list comprehension, and a lambda:
> >>> reduce(lambda a, b: a+b, [y for y in x])
> But I don't really like lambda, is there a better way to do this?
reduce (operator.add, [y for y in x])
More information about the Python-list