Recursion limit

Easysys Module Programs · 13 of 20

Write a Python program that reads the recursion limit and handles RecursionError.

Advertisement
Output
1000
RecursionError caught

Approach

  1. sys.getrecursionlimit().

Solution

Python
import sys print(sys.getrecursionlimit()) def dive(n):    return dive(n + 1) try:    dive(0)except RecursionError:    print("RecursionError caught")
Output
1000
RecursionError caught

Learn the concept

New to this topic? Read the lesson, then come back.

More sys module programs

← All 20 sys Module Programs

Leave a Comment