Felix - 3 months ago 11

Python Question

I have 2 identical lists

a = [a1,a2,a3]

b = [a1,a2,a3]

What is a most effective way to iterate over these 2 list simultaneously while i am interesting only in combination of different elements from both lists despite order, i.e a1a2 and a1a3. Combinations a1a1, a2a2, a3a3, a2a1, a3a1 i am interesting to skip, but interesting keep iterators values avaliable.

Want to re phrase questions:

interesting in possible combinations of 2 elements from list a = [a1,a2,a3]

Answer

```
from itertools import combinations
for i in combinations(['a1','a2','a3'],2):
print i
```