solutions

Sum of numbers in list

Define a function sum_of_numbers_in_list that receives a list of numbers
a_list of an unknown length and calculates the sum of those numbers using a
for loop. Do not use the sum function.

Examples:

>>> sum_of_numbers_in_list([])
0
>>> sum_of_numbers_in_list([4])
4
>>> sum_of_numbers_in_list([2, 3])
5
>>> sum_of_numbers_in_list([2, 3, 4])
9

Test Cases

test empty list - Run Test

def test_empty_list():
    assert sum_of_numbers_in_list([]) == 0

test list of 1 - Run Test

def test_list_of_1():
    assert sum_of_numbers_in_list([4]) == 4

test list of 3 - Run Test

def test_list_of_3():
    assert sum_of_numbers_in_list([2, 3, 4]) == 9

test list of 2 - Run Test

def test_list_of_2():
    assert sum_of_numbers_in_list([2, 3]) == 5