In Python you can specify a default value for a function parameter. It's nice for when a function has parameters that are "optional". You as the function definer can specify a specific default value in case the caller doesn't provide one.
A default value is created by using the assignment (=) operator in the function signature.
def get_greeting(email, name="there"):
print("Hello", name, "welcome! You've registered your email:", email)
get_greeting("[email protected]", "Lane")
# Hello Lane welcome! You've registered your email: [email protected]
get_greeting("[email protected]")
# Hello there welcome! You've registered your email: [email protected]
If the second parameter is omitted, the default "there" value will be used in its place. As you may have guessed, for this structure to work, optional parameters (the ones with defaults) must come after all required parameters.
Complete the get_punched and get_slashed functions. They both take 2 integers as arguments, health and armor.