• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes

Problem :

I am getting below error
maximum recursion depth exceeded while calling a python object

by (6.9k points)  

1 Answer

0 votes


Python lacks the tail recursion optimizations which is common in functional languages like lisp. In Python, recursion is limited to 999 calls 

1) You can change the recursion limit with sys.setrecursionlimit(n) until the maximum allowed for your platform:


2) You can try to convert the algorithm from recursive to iterative. If recursion depth is bigger than allowed by your platform, it is the only way to fix the problem. 

Further Readings:


by (36.1k points)  
edited by