Python Default Parameter Value
Default Parameter Value
The following example shows how to use a default parameter value.
If we call the function without argument, it uses the default value:
Example
def my_function(country = "Norway"):
print("I am from " + country)
my_function("Sweden")
my_function("India")
my_function()
my_function("Brazil")
Try it Yourself »
print("I am from " + country)
my_function("Sweden")
my_function("India")
my_function()
my_function("Brazil")
Related Pages
Python Functions Tutorial Function Call a Function Function Arguments *args Keyword Arguments **kwargs Passing a List as an Argument Function Return Value The pass Statement i Functions Function Recursion