I have an array which looks like this
[1, 0, 1 , 0 , 0, 1]
And I want to get those indexes that have 1 in it. So here I would get an array of <
you could use enumerate in a list comprehension:
a = [1, 0, 1 , 0 , 0, 1] b = [2**idx for idx, v in enumerate(a) if v] b
[1, 4, 32]