returning totals in functions of math

Peter Pearson pkpearson at nowhere.invalid
Sun Nov 8 14:00:34 EST 2020


On Sun, 8 Nov 2020 13:50:19 -0500, Quentin Bock <qberz2005 at gmail.com> wrote:
> Errors say that add takes 1 positional argument but 3 were given? Does this
> limit how many numbers I can have or do I need other variables?
> Here is what I have:
> def add(numbers):
>    total = 1
>    for x in numbers:
>           total += x
>    return total
> print(add(1999, -672, 84))

Your function "add" expects a single argument that is a list
of numbers.  You're passing it three arguments, each a number.
Try add([1999, -672, 84]).

-- 
To email me, substitute nowhere->runbox, invalid->com.


More information about the Python-list mailing list