Перейти к содержанию

Python sum() built-in function

Python sum() built-in function

From the Python 3 documentation Sums start and the items of an iterable from left to right and returns the total. The iterable’s items are normally numbers, and the start value is not allowed to be a string.

Examples

>>> sum([2, 4, 6])
# 12
>>> sum([10, 10, 10])
# 30