title: How can I get the index value of a list comprehension?
body: <p>Using the following approach I am able to create a dictionary of values:</p>
  
  <pre><code>{ p.id : {'total': p.total} for p in p_list}
  </code></pre>
  
  <p>This results in <code>{34:{'total':334}, 53:{'total: 123} ... }</code></p>
  
  <p>I would also like to list an index from the list so that I know which position <code>p.id</code> was in. I made a list like this:</p>
  
  <pre><code> c_list = [x for x in range(len(p_list))] 
  </code></pre>
  
  <p>And then tried to see how <code>c</code> could also be listed as part of the result. I thought I needed something like this:</p>
  
  <pre><code>{ (p,c) for p in p_list for c in c_list} 
  </code></pre>
  
  <p>but when I tried to implement it, I could not get <code>c</code> to be a value in the dictionary:</p>
  
  <pre><code>{ (p.id, c : {'total': p.total, 'position': c}) for p in p_list for c in c_list}
  </code></pre>