If you do not know how many keyword arguments that will be passed into your function, add two asterisk: **
before the parameter name in the function definition.
This way the function will receive a dictionary of arguments, and can access the items accordingly:
ExampleIf the number of keyword arguments is unknown, add a double **
before the parameter name:
def my_function(**kid):
print("His last name is " + kid["lname"])
my_function(fname = "Tobias", lname = "Refsnes")
Try it Yourself ยปArbitrary Kword Arguments are often shortened to **kwargs in Python documentations.
Track your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4