sum for sequences?
TomF
tomf.sessile at gmail.com
Thu Mar 25 02:50:23 EDT 2010
On 2010-03-24 14:07:24 -0700, Steven D'Aprano
<steven at REMOVE.THIS.cybersource.com.au> said:
> On Wed, 24 Mar 2010 15:29:07 +0000, kj wrote:
>
>> Is there a sequence-oriented equivalent to the sum built-in? E.g.:
>>
>> seq_sum(((1, 2), (5, 6))) --> (1, 2) + (5, 6) --> (1, 2, 5, 6)
>>
>> ?
>
> Yes, sum.
>
> help(sum) is your friend.
You might not want to be so glib. The sum doc sure doesn't sound like
it should work on lists.
Returns the sum of a sequence of numbers (NOT strings) plus the value
of parameter 'start' (which defaults to 0).
-Tom
More information about the Python-list
mailing list