Is it possible to run through a subset in a python list?
I have the following problem, I have two lists, list1 is very long and list2 is quite short. Now, I want to check which elements of the list2 are also in list1. My current version looks like this:
for item in list1:
if item in list2:
# do something
This takes a very long time. Is it possible to get a subset and then run through the list?
I need to do this many times.