When discovering solutions for the permutations of the list I have stumbled upon this hardcoded answer. I will list the code here:
def permutations(head, tail=''):
if len(head) == 0: print tail
else:
for i in range(len(head)):
permutations(head[0:i] + head[i+1:], tail+head[i])
permutations('abc')
Now, I totally do not understand, what happens when we call function from its body. Could you please explain to me, why it works, why it is needed here, and where I can read about this in more detail.
Thank you!