Consider the following code: How is the program using recursion and for loop what is the need for tail as a function argument in the below program?
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('abcd')