I have this code:
a = [12, 3, 4, 6, 7, 13, 21]
label = [1, 1, 1, 0, 1, 1, 0]
print([float(i) for i in a if label[i] == 1])
I just want to return the index of label which is 1, and then the index used for a to search a new list, so the result should be [12, 3, 4, 7, 13].
Can I write this in one line? Now my code problem is on i, I know it returns the item of a, not an index, how can I solve it?