ReferenceBuilt-in functions
sum()
Adds up numbers, beginning from start.
Signature
sum(iterable, start=0)Parameters
| Name | Means |
|---|---|
iterable | numbers to add |
start | the value to begin from |
Returns
The total.
Example
Python
print(sum([1, 2, 3]))
print(sum([1, 2], 10))
print(sum(n > 2 for n in [1, 2, 3, 4]))Output
6 13 2