Jan-30-2021, 10:30 PM
Recursion gets so abused. There are times that it is ideal - solving the Towers of Hanoi, for example. But a lot of students tend to try to use recursion when loops would do better. By better, consider the overhead that occurs every time the function is called, instead of simply moving through a loop. And, with libraries like itertools the looping gets even faster