Title here
Summary here
Variadic functions can be called with any number of trailing arguments. For example, print
is a common variadic function in Python.
Here’s a function that will take an arbitrary number of int
s as arguments.
Within the function, the type of nums
is equivalent to tuple
. We can call len(nums)
, iterate over it with a for
loop, etc.
To run the program, you can save the code into a file, e.g., variadic_functions.py
, and then run it.
Another key aspect of functions in Python is their ability to form closures, which we’ll look at next.
Next example: Closures.