Arbitrary number of arguments `*`


The values arrive as tuple.

examples/functions/sum.py
def mysum(*numbers):
    print(numbers)
    print(type(numbers))
    total = 0
    for s in numbers:
        total += s
    return total

print(mysum(1))
print(mysum(1, 2))
print(mysum(1, 1, 1))

x = [2, 3, 5, 6]

print(mysum(*x))

mysum(x)

(1,)
<class 'tuple'>
1
(1, 2)
<class 'tuple'>
3
(1, 1, 1)
<class 'tuple'>
3
(2, 3, 5, 6)
<class 'tuple'>
16
([2, 3, 5, 6],)
<class 'tuple'>
Traceback (most recent call last):
  File "examples/functions/sum.py", line 17, in <module>
    mysum(x)
  File "examples/functions/sum.py", line 6, in mysum
    total += s
TypeError: unsupported operand type(s) for +=: 'int' and 'list'