Recursion is a process of repeating something in a self similar way. When we define a recursive function, we define a function in terms of itself. That is, it can call itself to define itself!
A couple of examples where we'll use recursion are:
You know… fractals!
So… to create a recursive function definition:
RuntimeError: maximum recursion depth exceeded while calling a Python object
If we look at factorial again….
Let's try to reimplement factorial using recursion rather than a loop. →
Let's try to reimplement a program that continues to ask a question until the user says no by using recursion rather than a loop (how does the loop version go again?). →
Let's try to draw a tree using recursion. →