Python: define functions - how it works
This practical tip shows you how you can define your own functions with Python.
Python: define functions - how it works
You can easily define a function yourself in Python:
- First write the command "def" and then the name of the function and a colon. An example of this would be the command "def test ():". Also, don't forget the two brackets.
- Under this command you can now add further commands (shifted to the right with the tab key). These are executed as soon as the "test ()" function is executed.
Tip: You can find further programming tutorials on our Python programming language topic page. There we will show you, for example, how you can program loops in Python.