A reminder from the very first lesson of this course: return and print are different. This problem specifically checks what your function prints, not what it returns.
greet(name)
Print (don't return) "Hello, {name}!".
greet("Ada") // prints: Hello, Ada!
greet("world") // prints: Hello, world!
def greet(name):
print(f"Hello, {name}!")
Every other problem in this course has checked your function's return value — but real programs print things to the screen constantly (status messages, prompts, results for a human to read), and that's worth testing directly too.
This problem's tests capture whatever your code prints while greet runs, and compare that captured output to the expected text — your function's return value is ignored entirely here (in fact, greet doesn't even need a return statement; falling off the end of a function without one just returns None, which is fine).
If you instead wrote return f"Hello, {name}!", the tests would see empty output (nothing was printed) and fail — a good reminder of exactly the return-vs-print distinction from the very first lesson of this course, now showing up in a form where getting it backwards actually breaks the test.
def greet(name):
print(f"Hello, {name}!")
Sign in to join the discussion.
No comments yet. Be the first to ask a question.
Press Run to execute your code, or Submit to test and complete this problem.