title: How do I enumerate a list comprehension with two 'for's?
body: <p>I am trying to do</p>
  
  <pre><code>ls = [myfunc(a,b,i) for a in a_list for b in b_list]
  </code></pre>
  
  <p>but also pass in <code>i</code> into myfunc, which is an index starting at 0 and incrementing for each new element.</p>
  
  <p>For example:</p>
  
  <pre><code>a_list = 'abc'
  b_list = 'def'
  </code></pre>
  
  <p>should result in</p>
  
  <pre><code>ls = [myfunc('a','d',0),
        myfunc('a','e',1),
        myfunc('a','f',2),
        myfunc('b','d',3),
        myfunc('b','e',4),
        ...
        myfunc('c','f',8]
  </code></pre>
  
  <p>I know that I can use <code>enumerate()</code> for just the normal case, ie.</p>
  
  <pre><code>ls = [myfunc(a,i) for a,i in enumerate(a_list)]
  </code></pre>
  
  <p>But I can't figure out how to do it cleanly when there are two <code>for</code>s. I couldn't find this question posted previously either. </p>