Sum of a list

EasyFunction Programs · 5 of 39

Write a Python function to add up the numbers in a list.

Advertisement
Input
[6, 9, 4, 5, 3]
Output
27

Approach

  1. Loop and add.

Solution

Python
def total(numbers):    result = 0    for n in numbers:        result += n    return result print(total([6, 9, 4, 5, 3]))
Output
27

Learn the concept

New to this topic? Read the lesson, then come back.

More function programs

← All 39 Function Programs

Leave a Comment