I'm trying to write a Python program that outputs all possible strings formed by using
the characters c, a, t, d, o
and g
exactly once using recursion only.
so far I've got this:
i = ['c', 'a', 't', 'd', 'o', 'g']
counter = 0
def func(i):
global counter
i[counter], i[counter+1] = i[counter+1], i[counter]
print(i)
if counter != 5:
counter += 1
return func(i)
func(i)
EDIT: sorry for being "impolite", but I just copy-pasted the exercise from the book. This is just a pure text from the book.