Working with itertools.product and lists in python 3
You can use *pool
to "unpack" the list when calling product()
:
for n in itertools.product(*pool):
print(n)
This syntax expands the list pool
into separate positional parameters.
itertools.product(pool[0],pool[1],...pool[len(pool)-1]) is equivalent to itertools.product(*pool)
import itertools
F = ['UUU', 'UUC']
I = ['AUU', 'AUC', 'AUA']
pool=[F,I]
for n in itertools.product(*pool):
print(''.join(n))