James G. answered 05/16/18
Tutor
4.9
(1,012)
Tutor
The *args in a function header represents a variable number of arguments. This should be used if you have a function that needs to handle a variable number of arguments. Examples of these kind of functions are print(), or range(). The args variable would present the passed arguments as a list. Each element is one of the passed arguments.
The **kwargs is a way of dealing with key word arguments (keyword=value). These are used often for arguments that may or may not be provided especially after a variable number of arguments. This syntax allows calls to recognize that this isn't just another one of the variable arguments. The print() function for example has a number of optional arguments that use this kind of argument. The kwargs would present these passed arguments as a dictionary. The keys represent the keywords, and the values represent the argument values.