Input:
pos_1= 'AVNMHDRW'
pos_2= 'KNTHDYBW'
pos_3= 'KVNGSDRB'
Trying to find all possible triplets using one item from pos_1, one from pos_2, and one from pos_3
I'm trying to figure out how to use itertools.product(*) but I'm a little confused
Ultimately, I want to create a list (or generator object) of all the different possibilities by taking one from pos_1 then one from pos_2 and then one from pos_3
Example output:
'AKK','ANV','WWB'
pos_1 stands for position one and so on for pos_2 and pos_3.
See this answer: In python is ther a concise way to a list comprehension with multiple iterators.
In your case:
You can make such generator using generator expression:
Simple:
This can be iterated over; if you want a list, just pass it to
list
.What exactly is the issue?
Edit: This produces tuples of the items from each source. If you want to join them back into strings, you can do that manually when you iterate:
or to create the list, you can use a list comprehension: