sum up numbers in a list

Terry Reedy tjreedy at udel.edu
Tue Aug 26 22:34:51 EDT 2008



sharon kim wrote:

> is there a way to sum up all the numbers in a list?

 >>> help(sum)
sum(...)
     sum(iterable[, start]) -> value

     Returns the sum of an iterable of numbers (NOT strings) plus the value
     of parameter 'start' (which defaults to 0).  When the iterable is
     empty, returns start.

 >>> L=[28,39,20,78490,37373,22,2,33,4,5]
 >>> sum(L)
116016




More information about the Python-list mailing list