I have multiple strings on different lines where I want to get all of the possible permutations without changing the order:
for example:
er r er
er er r
which would give me:
er r er
er er r
er r r
er er er
Is there a way to do this is python? If this is a duplicate please advise but I was not able to find one.
This is different from questions like Finding all possible permutations of a given string in python where only one string is used
Update [Still does not work]
import itertools
with open(in_file) as f:
lis = list(f)
print (lis)
print([' '.join(x) for x in itertools.product(*map(set, zip(*map(str.split, lis))))])
[Error]
[['er', 'r', 'er'], ['er', 'er', 'r']]
Traceback (most recent call last):
File "test.py", line 37, in <module>
print([' '.join(x) for x in itertools.product(*map(set, zip(*map(str.split, S))))])
TypeError: descriptor 'split' requires a 'str' object but received a 'list'