Deviopath › Python

Sum of a List

Easy · Lists

A for loop visits every item of a list in order. Python also has a built-in sum() function that does this for you.

Write a function total(numbers) that returns the sum of all numbers in the list. An empty list sums to 0.

Next: Even or Odd