**kwargs

say it: “STAR STAR KWARGZ” /ˈstɑr ˈstɑr ˈkwɑrɡz/

Lets a function accept any number of keyword arguments, collected as a dictionary.

What does **kwargs do?

**kwargs lets a function accept any number of keyword arguments. Inside the function they arrive together as a dictionary.

def make_profile(**details):
    print(details)

make_profile(name="Ana", city="Austin")
# {'name': 'Ana', 'city': 'Austin'}

Level: Apprentice · More Python terms at this level

Updated