I need to create every combination for list1, but add list2 to every combination of list1.
For example, this creates a combination for every value for list1:
list1 = ["a", "b" , "c"]
list2 = ["d", "e"]
list(itertools.combinations(list1, 2))
[('a', 'b'), ('a', 'c'), ('b', 'c')]
But I would like the result to be:
[('a', 'b', 'd', 'e'), ('a', 'c'', d', 'e'), ('b', 'c', 'd', 'e')]
I have tried these common approaches, but am getting undesired results:
list1 = ["a", "b" , "c"]
list2 = ["d", "e"]
print(list(itertools.combinations(list1, 2)).extend(list2))
None
print(list(itertools.combinations(list1, 2)) + list2)
[('a', 'b'), ('a', 'c'), ('b', 'c'), 'd', 'e']
print(list(itertools.combinations(list1, 2) + list2))
TypeError: unsupported operand type(s) for +: 'itertools.combinations' and 'list'
Any help would be appreciated. Thanks.
[('a', 'b'), ('a', 'c'), ('b', 'c')]didn't come from usingitertools.combinations?