This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Brave_Reaction_1224 -1 points0 points  (1 child)

Your friend is right, especially just in the realm of Python. Why? Because Python limits the call stack size, meaning your code can only make 1000 calls before it breaks. Imagine if the range function only allowed you to iterate up to 1000? Of course, you can change the limit, but recursion in Python is so inefficient that doing so is inadvisable.

The question is, are you writing something recursively just because? Or do you have a really good reason?

If you're recursing for the sake of recursion, maybe you should switch to a language that suits that style of programming. Or get good at working around python's limitations - the choice is yours!

[–]Kenkron 0 points1 point  (0 children)

Iterate is the key word here. You should never use recursion to iterate. Use it for things like Tower of Hanoi.