def add(a, b, c):
return a + b + c
nums = [1, 2, 3]
print(add(*nums)) # 6
3. Unpack Dictionaries (**)
def greet(name, age):
print(f"Hello {name}, you are {age} years old.")
person = {"name": "Alice", "age": 25}
greet(**person)
# Hello Alice, you are 25 years old.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In Python, unpacking means expanding a collection (like a
list,tuple,set, ordict) into individual elements.1. Unpack Lists / Tuples
With
*(extended unpacking)2. Unpack in Function Calls
3. Unpack Dictionaries (
**)4. Merge Collections
5. Ignore Values with
_Read More: