I have a python program with two lists that look like the example below:
list1=["a","b","c","d"]
list2=[0,1,1,0]
Is there a elegant way to create a third list, that contains the elements of list1 at the position where list2 is 1? I am looking for something similar to the numpy.where function for arrays or better the elegant way:
array1=numpy.array(["a","b","c","d"])
array2=numpy.array([0,1,1,0])
array3=array1[array2==1]
Is it possible to create a list3 equivalent to array3, containing in this example "b" and "c" or do I have to cast or to use a loop?
array3.tolist()?