I have the following Python list (can also be a tuple):
myList = [\'foo\', \'bar\', \'baz\', \'quux\']
I can say
>>&g
Another possible solution:
sek=[]
L=[1,2,3,4,5,6,7,8,9,0]
for i in [2, 4, 7, 0, 3]:
a=[L[i]]
sek=sek+a
print (sek)
like often when you have a boolean numpy array like mask
[mylist[i] for i in np.arange(len(mask), dtype=int)[mask]]
A lambda that works for any sequence or np.array:
subseq = lambda myseq, mask : [myseq[i] for i in np.arange(len(mask), dtype=int)[mask]]
newseq = subseq(myseq, mask)