Passing optional parameters to a function in Python

Python allows function arguments to have default values; if the function is called with no argument, the argument gets its default value. In addition, arguments can be specified in any order using named arguments.


 (`Hello`,` Archie, Good morning! Come on in`) (`Hello`,` Richie, How do you do? Come on in`) 

The messages msg and msg2 are optional because they have default values. name is a required argument because it has no default.

If greet is called with only one argument, the default is msg &"Good morning", and by default msg2 &"Come in." If greet is called with two arguments, the default for msg2 is "Come in."

In most languages, we need to call a function with three arguments. But in Python, arguments can be specified by name in any order.

Get Solution for free from DataCamp guru