def welcome() -> None: """Welcome the user to the Functions page""" print("Hello There!") welcome()
Hello There!
def welcome() -> None: """Welcome the user to the Functions page""" print("Hello There!") welcome()
Hello There!
In python functions are used so that you don't have to re-write code. When writing functions start by defining it
def my_function() -> None:
Here the -> None
is used to show that nothing gets returned by this function. It is another form of documentation.
Next you need to add a docstring. Docstrings are like comments but for functions, you can still use comments in functions though
def my_function(): """This is a docstring"""
Docstrings can also be multi-line and should be broken up if lines get too long.