Say I have a list of strings, mylist, from which I want to extract elements that satisfy a condition in a another list, idx:
mylist = ['a','b','c','d']
idx = ['want','want','dont want','want']
What I want as output is:
['a','b','d']
which is a list of elements that I 'want'
How can this by done?
[mylist[i] for i,x in enumerate(idx) if x == 'want']