[Tutor] Python programming question related to Return/Print statement

eric grunfeld grunfelderic at gmail.com
Fri Aug 14 13:45:56 EDT 2020


Good Afternoon Everyone:

I  have been seeking to rectify my mistake in running this program via
Python.

Here it is:

def format_name(first_name, last_name):
    return "Name " + first_name + ", " + last_name
    return string

print(format_name("Ernest", "Hemingway"))
# Should return the string "Name: Hemingway, Ernest"

print(format_name("", "Madonna"))
# Should return the string "Name: Madonna"

print(format_name("Voltaire", ""))
# Should return the string "Name: Voltaire"

print(format_name("", ""))
# Should return an empty string

However, after running the program, this has been the response:
Incorrect

Not quite, format_name('Ernest', 'Hemingway') returned Name
Ernest, Hemingway, should be Name: Hemingway, Ernest.

It appears to be how I have programmed my return statement.

"return "Name " + first_name + ", " + last_name"

I look forward to your thoughts or comments that you may have on this
matter.

All the best,
Eric


More information about the Tutor mailing list