I want to combine elements in different lists. For example, here are 3 lists.
list_a : [ 1,2,3 ]
list_b : [ 4,5,6 ]
list_c : [ 7,8 ]
Selecting elements from list_b
and list_c
is mutually exclusive. When including an element from list_b
, I'd like to also include an element from list_bb
; when including an element from list_c
, I'd like to also include an element from list_cc
.
list_bb : [ 14,15,16 ]
list_cc : [ 17,18 ]
I wrote this code:
global sum_list=[]
for a in list_a:
for b in list_b:
for bb in list_bb:
sum_list.append([a,b,bb])
for a in list_a:
for c in list_c:
for cc in list_cc:
sum_list.append([a,c,cc])
Is there any better way to get the same result?