title: How to extract elements from a list using indices in Python?
body: <p>If you have a list in python, and want to extract elements at indices 1, 2 and 5 into a new list, how would you do this?</p>
  
  <p>This is how I did it, but I'm not very satisfied:</p>
  
  <pre><code>&gt;&gt;&gt; a
  [10, 11, 12, 13, 14, 15]
  &gt;&gt;&gt; [x[1] for x in enumerate(a) if x[0] in [1,2,5]]
  [11, 12, 15]
  </code></pre>
  
  <p>Is there a better way?</p>
  
  <p>More in general, given a tuple of indices, how would you use this tuple to extract the corresponding elements from a list, even with duplication (e.g. tuple <code>(1,1,2,1,5)</code> produces <code>[11,11,12,11,15]</code>).</p>