Unpacking an Iterable
Learn how to unpack an iterable into a parameter list or a sequence using the * operator.
We'll cover the following...
We'll cover the following...
Unpacking an iterable to a parameter list
Here is a simple function that multiplies three numbers:
def mult3(a, b, c):
return a*b*c
x = mult3(2, 3, 5) # 30
Suppose the arguments you needed were already in a list. You can use the unpacking operator, *, to “unpack” the values, as shown below.
In this case, *p is equivalent ...