Write a recursive function called that takes a string of single names separated by spaces and prints out all possible combinations (permutations), each combination on a new line.
def all_permutations(permList, nameList):
# TODO: Implement method to create and output all permutations of the list of names.
if nameList == len(permList) - 1:
return nameList
else:
for x in range(permList, len(nameList)):
permList[nameList], permList[x] = permList[x], permList[name_List]
return all_permutations(permList, nameList + 1)
permList[nameList], permList[x] = permList[x], permList[name_List]
if __name__ == "main":
nameList = input().split(' ')
permList = []
all_permutations(permList, nameList)