For more information on concepts covered in this lesson, you can check out Python args and kwargs: Demystified.
Using args and kwargs
kwargs. There are two other types of Python optional arguments you’ll need to know about. In the earlier section of this course, you’ve learned how to create a function with an optional argument.
00:14 If you need more optional arguments, then you can create more parameters with default values when defining the function. However, it is possible to define a function that accepts any number of optional arguments.
00:26 You can even define functions that accept any number of keyword arguments. Keyword arguments are arguments that have a keyword and a value associated with them, as you’ll see later on in this section.
To define functions with a variable number of input arguments and keywords, you’ll need to learn about
kwargs. In this course, we’ll look at the most important points that you need to know about these Python optional arguments. And if you want to explore further, you can look at this Real Python tutorial.
00:58 In the next section of the course, you’ll see how to create functions which can accept any number of arguments.
Become a Member to join the conversation.