[Solved] Get an item from a list if its index is on another list


You can do this with a list comprehension.

For example:

mylist = [[0.0,0.0,0.1], [0.4,0.23,0.175], [0.0,1.,0.5], [0.0,0.03,0.1], [0.02,0.0,0.3]]
indices = [0,2,3]
result = [mylist[i] for i in indices]

result is now [[0.0, 0.0, 0.1], [0.0, 1.0, 0.5], [0.0, 0.03, 0.1]]

2

solved Get an item from a list if its index is on another list