0

to visually understand my question:

go from this..

 list1 = [3, 4, 78]
 list2 = [24, 35, 2, 9, 8]

to this..

list3 = [[3, 24], [3, 35], [3,2], [3, 9] [3, 8], [4, 24], [4, 35], [4,2], [4, 9] [4, 8]]

I tried different variations of this to no avail

list3 = [list(pair) for pair in zip(list1, list2)] 
tosin
  • 37
  • 5
  • 1
    [`itertools.product()`](https://docs.python.org/3.6/library/itertools.html?highlight=product#itertools.product) is what you are looking for (are you deliberately excluding all the `78` pairs). – AChampion Jul 23 '18 at 20:17

1 Answers1

0

I'm assuming you're missing the last set in your example (78 matched up with each value in list2). It looks like you just need a list comprehension.

[[x, y] for x in list1 for y in list2]
[[3, 24],
 [3, 35],
 [3, 2],
 [3, 9],
 [3, 8],
 [4, 24],
 [4, 35],
 [4, 2],
 [4, 9],
 [4, 8],
 [78, 24],
 [78, 35],
 [78, 2],
 [78, 9],
 [78, 8]]
W Stokvis
  • 1,409
  • 8
  • 15