08Sum a List

    Very easylistsloops

    Write total(numbers) that returns the sum of all numbers in the list.

    Practise the loop: try it without Python's built-in sum. An empty list adds up to 0.

    Examples

    Example 1
    >>> total([1, 2, 3, 4])
    10
    Example 2
    >>> total([])
    0

    Run examples checks the 2 examples above. Submit runs all 6 tests, including hidden edge cases, and marks the challenge solved.

    solution.py
    Loading Python…

    Test results show up here

    Write total in the editor, then run the examples. Use print() freely: its output is shown for each test.