4

This is the sequence:

l = [['A', 'G'], 'A', ['A', 'C']]

I need the three element sequence back for each permutation

all = ['AAA','GAA','AAC','GAC']

I can't figure this one out! I'm having trouble retaining the permutation order!

1 Answer 1

6

You want the product:

from itertools import product

l = [['A', 'G'], 'A', ['A', 'C']]

print(["".join(p) for p in product(*l)])
Sign up to request clarification or add additional context in comments.

2 Comments

brilliant solution +1 for product
Of course this only works because all of his values are 1-character strings… but then if that weren't true, his data format would be a horrible mess in the first place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.