def greet():
message = "Hello"
print(message)
greet()Line-by-line explanation
- The function is defined.
messageis created locally inside it.- The function can display message.
- The call runs the function.
Prefer parameters and return values over changing global variables. They make each function’s inputs and outputs visible.