def addition(*args): """Adds any quantity of numbers""" def _initial_value(): return None if not args else 0 return reduce(_execute, flatten(args), _initial_value())
def test_flatten_nested_lists(): assert flatten([[[1, 2, 3]], 1]) == [1, 2, 3, 1]
def test_flatten_a_flattened_list(): assert flatten([1, 2, 3, 4]) == [1, 2, 3, 4]
def test_flatten_list_and_number(): assert flatten([1, [2, 3, 4]]) == [1, 2, 3, 4]
def test_flatten_an_empty_list(): assert flatten([]) == []