sum()
Adds up the numbers in a sequence.
Syntax
sum(arr, start=0)
Description
Adds up all the numbers in a sequence like a list/tuple. An optional starting value can be added.
Returns
The total value.
Example
Loading editor…
Expected output
60 106
When to use?
When computing a cart total, a score total, or an average (sum/len).