Max Recursion Depth Exceeded Python Interview