Solution 1

def sum_multiple(*args):
    if not args:
        raise AttributeError("You must pass at least one number to sum")
    return sum(args)

Sum Multiple Terms

Write a function that receives multiple arguments and returns the sum of them. Example:

sum_multiple(2, 3, 5, 7) == 17
sum_multiple(2, 3) == 5

If no arguments are provided, an Exception should be raised. Check the test cases for the complete spec.

Test Cases

test sum multiple terms - Run Test

def test_sum_multiple_terms():
    assert sum_multiple(2, 3) == 5
    assert sum_multiple(2, 3, 5, 7) == 17

test sum with no elements raises error - Run Test

import pytest

def test_sum_with_no_elements_raises_error():
    with pytest.raises(AttributeError):