I want to intersect two list. But the lists are of different types, one is list of tuples and the other is list of integers. As a result I need a final list of tuples.
List 1: [(1.0, 2481), (0.11764705882352941, 2), (0.033, 2), (0.0, 2479), (0.0, 2478), (0.0, 2477)]
List2 : [2481,2, 2477]
Desired results:
[(1.0, 2481), (0.11764705882352941, 2), (0.0, 2477)]
I want to include only one tuple in final list which comes first If you specifically look at this case (0.11764705882352941, 2), (0.033, 2)
, I only want to include this (0.11764705882352941, 2)
tuple into final list.
I can loop through the list of tuples but I am not sure this will be efficient on large lists.
Is there any better way to do it?
Thanks in advance!