Recursion

This lesson will explain the concept of recursion in Python.

Definition #

Recursion is the process in which a function calls itself during its execution. Each recursive call takes the program one scope deeper into the function.

The recursive calls stop at the base case. The base case is a check used to indicate that there should be no further recursion.

Imagine recursive calls as nested boxes where each box represents a function call. Each call makes a new box. When the base case is reached, we start moving out of the boxes one by one:

Get hands-on with 1200+ tech skills courses.