It is now time to organize/refactor our code! When you begin, this is a strange process since the final code does the same as before. However, refactoring is the only way to create a code easy to maintain and expand.
This post is part of the Discover Python and Patterns series
Define a function
In the previous programs, we used existing functions like print() or input(). We can also create our own functions using the def statement:
def printHello():
print("Hello!")
The syntax is:
def <function name>(<arguments>):<function body>
We can choose a function name as for variable …