Passing a dictionary as keyword arguments to a function in Python


Python tip:

You can use ** to unpack a dictionary as keyword arguments (kwargs) for a function.

👇

user = {"name": "Jan", "surname": "Giacomelli"}


def print_full_name(name, surname):
    print(f"{name} {surname}")


print_full_name(**user)
# => Jan Giacomelli