You have been given components of a function that receives user's first and last names as arguments, and in case if last name is not provided, defaults to 'Doe'. The function constructs a greeting message using these names and returns the said message. The existing lines of code are in random order. Your task is to reorder these lines to create a correct Python function that prints "Hello John Doe!" when called with one argument ('John'), and "Hello Jane Smith!" when called with two arguments ('Jane', 'Smith').
Function, arguments and parameters
Creating a customized greeting function with default values
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
message = f"Hello {first_name} {last_name}!"
print(greet_user("Jane", "Smith"))
return message
def greet_user(first_name, last_name="Doe"):
print(greet_user("John"))
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.