title: Accessing the index in 'for' loops
body: <p>How do I access the index while iterating over a sequence with a <code>for</code> loop?</p>
  <pre><code>xs = [8, 23, 45]
  
  for x in xs:
      print(&quot;item #{} = {}&quot;.format(index, x))
  </code></pre>
  <p>Desired output:</p>
  <pre class="lang-none prettyprint-override"><code>item #1 = 8
  item #2 = 23
  item #3 = 45
  </code></pre>