I have a boolean (numpy) array. And I want to count how many occurrences of 'True' are between the Falses.
Eg for a sample list:
b_List = [T,T,T,F,F,F,F,T,T,T,F,F,T,F]
should produce
ml = [3,3,1]
my initial attempt was to try this snippet:
i = 0
ml = []
for el in b_List:
if (b_List):
i += 1
ml.append(i)
i = 0
But it keeps appending elements in ml for each F in the b_List.
EDIT
Thank you all for your answers. Sadly I can' accept all the answers as correct. I've accepted Akavall's answer because he referred to my initial attempt (I know what I did wrong now) and also did a comparison between the Mark's and Ashwinis posts.
Please don't take as a define answer the accepted solution, since both the other suggestions introduce alternative methods what work equally well