title: How to get the index of the current iterator item in a loop?
body: <p>How to obtain the index of the current item of a Python <a href="https://docs.python.org/3.7/glossary.html#term-iterator" rel="noreferrer">iterator</a> in a loop? </p>
  
  <p>For example when using regular expression <code>finditer</code> function which returns an iterator, how you can access the index of the iterator in a loop.</p>
  
  <pre><code>for item in re.finditer(pattern, text):
      # How to obtain the index of the "item"
  </code></pre>