Generally, recursion means calling the same thing itself. In python, the defined function can call itself within the same function definition, and we will call it a recursive function.
Following is the pictorial representation of calling the same function (recursive function) itself in python.
While creating the recursive functions, you need to make sure that there is a condition that stops the recursion; otherwise, the function calls itself infinitely. You will get an exception like maximum recursion depth exceeded.
Following is the example of defining the recursive function in python.
If you observe the above example, we created the calculate function and we are calling the same calculate function inside of the function body.
When you execute the above python example, you will get the result as shown below.
As discussed, if you create a recursive function without any condition to stop the recursion you will get a recursion exception.
When you execute the above python example, you will get an exception like as shown below.
This is how you can implement the function recursion in python to call the same function based on your requirements.