To begin, if you want to understand recursion, you must understand what is recursion.
This explain pretty much the concept of recursion. :D
In the programming world, you can find recursive algorithms, such as sorting ones, and you can guess they aren't looping on themselves infinitely, we always add a return condition to be sure we won't have an infinite loop.
FYI we don't do infinite recursive function because it would pollute the "call stack". This stack keeps track of which function was called, and from where it was called, to be able to get back there when we'll met a return statement.
Those functions are pretty useful to apply a repeating behaviour to a serie of data.
For example :
def bubbleSort(data: list) -> list:
output = 
if len(data) > 2:
middle_element = len(data) // 2
new_list = bubbleSort(data[:middle_element]) + bubbleSort(data[middle_element:])
for element in new_list:
return [min(*data), max(*data)]
(actually this function isn't working as intended, it was created only to show you the concept of recursion)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.