Help students build intuition about recursion in Python by comparing each recursive call to a function call, which may be more intuitive for students in introductory classes.

  • When a function calls another function in Python, the first function pauses and then waits for the next functions output.
    • Similarly, a recursive call is simply calling itself over and over again.
  • Recursion isn’t special; it’s simply the rule for how function calls work. Make this clear to your students by tracing through a simple recursive function (e.g. adding up the numbers from 1 to n).

More about this tip

External Source

Ran Libeskind-Hadas at CSNYC Tip-A-Thon.