...

/

Unpacking an Iterable

Unpacking an Iterable

Learn how to unpack an iterable into a parameter list or a sequence using the * operator.

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 ...

svg viewer
Access this course and 1400+ top-rated courses and projects.