Using ** for Unpacking Dictionaries in Python


Unpack key-value pairs from a dictionary into function arguments.

Source Code

def greet(name, age):
    print(f"Hello, {name}. You are {age} years old.")
person = {"name": "John", "age": 30}
greet(**person)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments