Harrison - 5 months ago 41

Python Question

Say there is two lists.

`List1 = [1,3,5,7,9]`

List2 = [2,4,6,8,10]

I want to print every possibilities with no repeats that meet the pattern below:

`Res = [odd,even,odd,even,odd,even,odd,even,odd,even]`

For example,

`Res = [1,2,3,4,5,6,7,8,9,10]`

Res = [1,2,5,4,3,6,9,8,7,10]

Res = [3,2,1,4,9,6,5,10,7,8]

I tried to use itertools.product but I didn't know how to iterate by it.

Answer

```
>>> List1 = [1,3,5,7,9]
>>> List2 = [2,4,6,8,10]
>>> import itertools
>>> list(map(lambda x:[item for sublist in list(zip(*x)) for item in sublist], (itertools.product(itertools.permutations(List1), itertools.permutations(List2)))))
```