Get index of first boolean group

Hi,
is it possible to group Trues in a Boolean list, and recall the index of first item of that group ?
image
I have this list L1 = [0,1,1,0,0,0,1,1,1] and has a similar index list i1 = [0,1,2,3,4,5,6,7,8]
Is it possible to group 1’s in this list and get index if its first item. so I get i2 = [1, 8]

So everytime there is more than one 1, it groups and return me first 1’s index.
L = [1,1,1,1,0] gives me i = [1]

1 Like

@hassan.orion ,

i know i am not answering your question directly… but it can be a step

Hi @hassan.orion ,

Itertools (python) has a function for this.

2 Likes

Hello,
I don’t know if that’s what you’re looking for

cordially
christian.stan

1 Like