How to get the count of consecutive 0's and 1's in a binary list in python

Viewed 12

I have a binary list that contains 0's and 1's. How do I get the count of consecutive 0's and 1's in another list? e.g , if X= [1,1,1,1,0,0,1,1,1,0,0]. I should get [4,2,3,2] as the output. Thanks.

0 Answers
Related