title: How to get the index in the 'in' statement in Python
body: <p>I wrote an <code>if</code> statement like:</p>
  
  <pre><code>if word in vocab:
      print word
  </code></pre>
  
  <p>However, I also would like to know the matched <code>word</code> index in <code>vocab</code>. </p>
  
  <p>Is there any way in Python can do this?</p>
  
  <p>I just come up a solution that use <code>vocab.index(word)</code> to get the index, but this way go through the array twice (one in <code>if</code> statement, one call <code>index()</code>). I wonder there should be more efficiency method.</p>
  
  <p>Thanks.</p>