I am trying to solve the following problem:
I have a python list with multiple different elements and each of them can be repeated:
list =  ['a', 'a', 'b', 'a', 'foo','foo','foo', 'c','foo', 'd', 'foo','foo']
And I want to know how many times a certain element, e.g. foo appears n times in a row, without counting the first appearance. Thus, the counting of list would go as follows:
list =  ['a', 'a', 'b', 'a', 'foo','foo','foo', 'c','foo', 'd', 'foo','foo']
         +0,  +0 , +0 , +0   ,+0  , +1  , +1  , +0 , +0  , +0 ,  +0  ,  +1    = 3
The desired output would be 3 in this case.
Is there any clean way to do it?
I saw this, but this is for a specific number of appearances. In my case the number of appearances in a row is not predetermined. I think I neither could use this other for the same reason.
 
     
     
     
    