Lets say I am having the following lists:
letters = ['a','b','c']
numbers = ['one','two']
others = ['here','there']
And I want all the possible compinations of all the values. I am doing the following:
from itertools import permutations
b = []
b.extend(letters)
b.extend(numbers)
b.extend(others)
result1 = list(permutations(b,2))
The results are ok. But what I want more specifically is to know the 'types' of compinations. For example result should be:
('a','b','letters-letters')
or
('a','one','letters-numbers')
('one','a','letters-numbers')
I am using the following code:
from itertools import product
result2=[]
result2.extend([x+('letter-letter',) for x in list(permutations(letters ,2))])
result2.extend([x+('number-number',) for x in list(permutations(numbers,2))])
result2.extend([x+('other-other',) for x in list(permutations(others,2))])
result2.extend([x+('number-letter',) for x in list(product(numbers,letters))])
result2.extend([x+('number-letter',) for x in list(product(letters,numbers))])
result2.extend([x+('number-others',) for x in list(product(numbers,others))])
result2.extend([x+('number-others',) for x in list(product(others,numbers))])
result2.extend([x+('letters-others',) for x in list(product(letters,others))])
result2.extend([x+('letters-others',) for x in list(product(others,letters))])
Is there a more quick,elegant way of doing this?