Repaso
Español
PythonCorePY-46

What does the last line print?

def greet(name):
    print("Hi", name)

result = greet("Ana")
print(result)

Options

  1. Hi Ana
  2. None (Correct option)
  3. ""
  4. 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.

Key terms

Practice this question in Repaso