I have 2 lists a = [2, 6, 12, 13, 1, 4, 5]
and b = [12, 1]
. Elements in list b
are a subset of list a
.
From the above pair of lists, I need to create a list of tuples as following :
[(12,6),(12,2),(1,13),(1,12),(1,6),(1,2)]
Basically, at the point of intersection of list b
and list a
, so from above e.g a
and b
first intersection point is at index 2
, the value 12
. So create a tuple with the first element from list b
and the second element from list a
. I am trying this in python, any suggestion for efficiently doing creating this tuple ? Please note, each list can have 100 elements, in it.