title: python reset enumerate index of a list on condition
body: <p>i want to loop through list1 and append an increasing value to list2 until it reaches a value in list1 where <code>value != 0</code> then that increasing value resets back to <code>0</code> and starts enumerating from <code>0</code> again. </p>
  
  <p>I tried the following:</p>
  
  <pre><code>list1 = [0,0,0,25,0,0,0,20,0,0]
  list2 = []
  
  for i,v in enumerate(list1):
      if v == 0:
          list2.append(i+1)
      else:
          list2.append(0)
  </code></pre>
  
  <p>But this returns:</p>
  
  <pre><code>list2 = [1,2,3,0,5,6,7,0,9,10]
  </code></pre>
  
  <p>Desired output: </p>
  
  <pre><code>list2 = [1,2,3,0,1,2,3,0,1,2]
  </code></pre>