What does the last line print?
def greet(name):
print("Hi", name)
result = greet("Ana")
print(result)Options
- Hi Ana
- None (Correct option)
- ""
- An error
Answer
None
Why
A function without a return statement returns None automatically.
greet prints "Hi Ana" on the screen (that is a side effect), but the value it gives back is None. So result is None and the last line prints None.
Remember
print() shows text; return gives a value back. No return → None.