This function, applied to an iterable , returns the sum of its elements. There are two general
forms:
S
sum(S) sum(S,I)
In the second form, the summing process starts with the
initial value .
Examples:
I
>>> L=[1,2,3,4] >>> sum(L) 10 >>> sum(L,1000) 1010 >>> sum((), 1000) 1000