Argument UnpackingΒΆ

We can use * operator to unpack the arguments out of a list, tuple and ** operator to unpack the arguments out of a dictionary.

def func(a, b, c):
    print(a, b, c)
list1 = [1, 2, 3]
tuple1 = (4, 5, 6)
dict1 = {'a': 7, 'b': 8, 'c': 9}
func(*list1)
1 2 3
func(*tuple1)
4 5 6
func(**dict1)
7 8 9