This is my code so far:
a_string = 'abcd'
final_list = [[]]
length = len(a_string)
groups =[list(a_string)] * 3
for i in groups:
final_list = [x+[y] for x in final_list for y in i]
permutations = [''.join(item) for item in final_list]
print(permutations)
It does what i want it to do but I need help to format the output. At the moment the output is generated like this:
['aaa', 'aab', 'aac', 'aad', 'aba', 'abb', 'abc', 'abd', 'aca', 'acb', 'acc', 'acd', 'ada
but what i want it to look like it this:
aaa
aab
aac
aad
...
so separate lines for each result and no quotation marks or commas.
What should I change?