Unpacking Collections Using * in Python


Unpack elements from a list or tuple into function arguments.

Source Code

def divide(a, b):
    return a / b
numbers = [20, 4]
result = divide(*numbers)  # Equivalent to divide(20, 4)
print(result)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments