Skip to content

Instantly share code, notes, and snippets.

@maxcheung89
maxcheung89 / gist:d5115d46f27edb085bf4da6057c3e0df
Last active September 3, 2022 05:37
6. Question 6 Complete the body of the format_name function. This function receives the first_name and last_name parameters and then returns a properly formatted string. Specifically: If both the last_name and the first_name parameters are supplied, the function should return like so:
def format_name(first_name, last_name):
if len(str(last_name)) == 0 and len(str(first_name)) == 0:
string = ""
elif len(str(first_name)) == 0:
string = "Name: "+ last_name
elif len(str(last_name)) == 0:
string = "Name: " + first_name
else:
string = "Name: "+last_name + ", "+ first_name