title: Conditionally enumerating items in python
body: <p>I'd like to enumerate those items in an iterable that satisfy a certain condition. I've tried something like</p>
  
  <pre><code>[(i,j) for i,j in enumerate(range(10)) if (3 &lt; j) and (j &lt; 8)]
  </code></pre>
  
  <p>(that tries to enumerate the numbers between 4 and 7 just for the sake of an example). From this, I get the result</p>
  
  <pre><code>[(4, 4), (5, 5), (6, 6), (7, 7)]
  </code></pre>
  
  <p>What I'd like to get is</p>
  
  <pre><code>[(0, 4), (1, 5), (2, 6), (3, 7)]
  </code></pre>
  
  <p>Is there a pythonic way to achieve the desired result?</p>
  
  <p>Note that in the actual problem I'm working on, I don't know in advance how many items satisfy the condition.</p>