Title here
Summary here
Here’s a function that will take an arbitrary number of int
s as arguments in Python.
Within the function, the type of nums
is equivalent to tuple
. We can call len(nums)
, iterate over it with for
, etc.
If you already have multiple args in a list, apply them to a variadic function using func(*slice)
like this.
To run the program, save the code in a file and execute it with Python.
Another key aspect of functions in Python is their ability to form closures, which we’ll look at next.