Introduction to Recursion

Learn about recursion and the recursive methods in Python.

Repetitions

There are two ways to repeat a set of statements in a function:

  • By using a while or for loop.
  • By calling the function from within itself.

The first method is known as iteration, and the second is known as recursion.

The functions that use iteration are called iterative functions, and those that use recursion are called recursive functions.

Recursive function

A Python function can be called from within its body. When we do so, it is called a recursive function.

Get hands-on with 1200+ tech skills courses.