sum()

noun

say it: “SUM” /sʌm/

A built-in Python function that adds up all the numbers in a list or other collection.

What does sum() do?

sum() adds up all the numbers in a list.

receipt = [4.50, 2.25, 8.00]
print(sum(receipt))  # 14.75

In a sentence

  • “The step counter uses sum() on the week's daily steps.”
  • “sum() added the receipt's prices to 14.75.”

Level: Apprentice · More Python terms at this level

Updated