Define and Call a Function
Challenge 2-1: Functions
Challenge 2-1: Functions
Let’s put together some of the things we’ve already learned and write some functions.
First we'll define a function in the interpreter:
>>> def say_hello():
print('Hello')
This function doesn’t have any parameters, but it still does something. That something that it does - printing the word "Hello" - is called the body of the function.
Now we'll call the function:
>>> say_hello()
Hello