Variadic Functions in Logo

<p><a href="./">Go by Example</a>: Variadic Functions</p>

<p><a href="https://en.wikipedia.org/wiki/Variadic_function"><em>Variadic functions</em></a> can be called with any number of trailing arguments. For example, <code>fmt.Println</code> is a common variadic function.</p>

Here's a function that will take an arbitrary number of <code>int</code>s as arguments.

```python
def sum(*nums):
    print(nums, ' ')
    total = 0

    for num in nums:
        total += num
    print(total)

if __name__ == "__main__":
    sum(1, 2)
    sum(1, 2, 3)

    nums = [1, 2, 3, 4]
    sum(*nums)

Variadic functions can be called in the usual way with individual arguments:

sum(1, 2)
sum(1, 2, 3)

If you already have multiple args in a list, apply them to a variadic function using func(*list) like this:

nums = [1, 2, 3, 4]
sum(*nums)

When you run this script, the output will be:

$ python script.py
(1, 2) 
3
(1, 2, 3) 
6
(1, 2, 3, 4) 
10

Another key aspect of functions in Python is their ability to form closures, which we’ll look at next.

Next example: Closures.

```