returning totals in functions of math

inhahe inhahe at gmail.com
Sun Nov 8 16:46:40 EST 2020


On Sun, Nov 8, 2020 at 1:51 PM 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))
>
> I have a multiply function above it but that was solved and I'm trying to
> figure everything out for each of the different math functions.
> Thank you
> --
> https://mail.python.org/mailman/listinfo/python-list


By the way, did you know about the `sum` function? It does basically what
your add function does, except I think you'd need to pass it an initial
value so it knows what type it's adding, or something like that.


More information about the Python-list mailing list