Python
RecursionError: maximum recursion depth exceeded
RecursionError
A function called itself too many times. Python's default limit is around 1000.
Common Causes
- Missing base case in recursion
- Infinite recursion (logic bug)
- Deeply nested data structures
- Mutual recursion without base case
Fixes
- 1. Add base case
def fib(n): if n <= 1: return n return fib(n-1) + fib(n-2) - 2. Use iteration instead
def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a+b return a - 3. Increase limit (rare)
import sys sys.setrecursionlimit(2000)
Still not fixed?
- • Search the exact error message on Stack Overflow or GitHub Issues
- • Check the official docs for the language or tool
- • Ensure your versions (Node, Python, npm, Docker) are up to date
- • Try in a minimal reproduction (new project, single file)
Related Errors
DuskTools That Might Help
All Errors
JavaScript Heap Out of MemoryModuleNotFoundErrorAddress Already in UseIndentationErrorCannot Find ModulePeer Dependency WarningCORS Policy BlockedTypeError: 'NoneType' Not SubscriptableMerge ConflictDocker Port Already AllocatedENOENT: No Such File or DirectoryKeyErrorMaxListenersExceededWarningDetached HEAD StateEACCES: Permission DeniedValueErrorNo Space Left on DeviceERR_REQUIRE_ESMFileNotFoundError