title: Python map lambda filter help using IF
body: <blockquote>
  <p>Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are:</p>
  <p>(a) even numbers, and<br />
  (b) from elements in the original list that had even indices</p>
  </blockquote>
  <p>I am looking for a solution to the above problem. As suggested <a href="http://www.toptal.com/python/interview-questions" rel="nofollow noreferrer">here</a> there is an easy way to solve it but I would like to know if there is a way I can use a combination of map, lambda and filter on the &quot;FULL&quot; input list.</p>
  <p>I am trying to do something like this but it doesn't work.</p>
  <pre><code>&gt;&gt;&gt; map(lambda i,x : x%2==0 or (i+1)%2==0, range(0,len(l)-1),l)
  [False, True, False, True, True]
  </code></pre>
  <p>Ideally I need to write something like (added &quot;x if&quot;) but that doesnt work. Any suggestions?</p>
  <pre><code>map(lambda i,x : ***x if*** x%2==0 or (i+1)%2==0, range(0,len(l)-1),l)
  </code></pre>