Python

Python Programs





Question:1

How to increase the recursion limit? in Python

sys.setrecursionlimit(n)


Set the maximum depth of the Python interpreter stack to n. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python. The highest possible limit is platform-dependent. see the below example.


import sys
sys.setrecursionlimit(1500)
def fun(i):
if i==0:return 0
else:return fun(i-1)
print fun(1001)