I'm trying to use a variable flist
consisting of a list of indices to retrieve the elements from features
list.
flist = [1, 3, 7]
features = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
Desired output:
['b', 'd', 'h']
Is there a way of retrieving the elements from features
using flist
directly? For example, when I try features[flist[i] for i in range(0,len(flist))]
I get an 'invalid syntax' error.
Thanks