Python: filtering lists by indices

I don’t know any method to do it. But you could use a list comprehension:

>>> [aList[i] for i in myIndices]

Leave a Comment