What is a more correct way of doing something in Python if this can be done both by looping and by recursion?
Generally, loops are more efficient. This is because each recursion call creates an item in the memory stack. There also can be a limit for the number of recursion calls, and when you exceed this number, you will get a runtime error. So, if you can to achieve a goal with the loop it is better to use them.