Python 101 : The keyword arguments and the "*" parameter


A keyword argument has the following format "name=value". We can pass a keyword argument to a function as follows:



We could also call the function without the keyword parameters, so that it will use the default values "beginning=0, end=10":


Another way to do it is to pass the keyword arguments without their names:


But if we want to make sure that the named keyword arguments are used, we use the "*" parameter before our keyword arguments as below. We get an error if they are not used:


We need to use our 
keyword arguments as below:


Comments

Leave as a comment:

Archive