Skip to Main Content

Python for Basic Data Analysis: 2.6 Functions - Arbitrary Keyword Arguments (**kwargs)

Get started on your learning journey towards data science using Python. Equip yourself with practical skills in Python programming for the purpose of basic data manipulation and analysis.

What are Arbitrary Keyword Arguments (**kwargs)?

**kwargs works the same as *args buy instead of accepting positional arguments, it accepts keyword arguments such as those from a dictionary (i.e. a dictionary of arguments).

Once again, the important thing here is the function of the unpacking operator (**) which is basically the same as the single asterisk but for dictionaries.

To sum up Arbitrary Arguments:

  • use a single asterisk (*) to unpack iterables
  • and use 2 asterisks (**) to unpack dictionaries


Use the function above to print the items in the dictionary below:
dict = {"First Name":"John", "Last Name":"Wick","Nickname":"Jojo", "Middle Name":"Candle"}