What is recursion, and what are its limits in Python?
Model answer
A function that calls itself, with a base case to stop. Python limits recursion depth (about 1000 by default) and does not optimise tail calls, so deep recursion raises RecursionError. For deep problems use loops or an explicit stack.
Learn this topic
Functions in Python: def, Arguments and return in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.