Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Using the Python kwargs Variable in Function Definitions

Zarata on April 15, 2020

The examples show how one might access the keys OR the values of the dictionary, but that leaves the question of why one would pass a dictionary as a whole rather than just keys or values. Have you a good example of how having each map item as a whole is uniquely useful within a function?

Mike K on June 7, 2020

@Zarata - Keyword arguments are dictionaries because you associate a name with a value. Here is the description of keyword arguments from the official documentation - keyword argument: an argument preceded by an identifier (e.g. name=) in a function call or passed as a value in a dictionary preceded by *.*

You will have to pass the whole dictionary to the function because keys and values alone are technically meaningless unless used together.

Become a Member to join the conversation.