Use map and filter instead of a for loop?
<p>How do I write an equivalent of the code below using map and filter?</p>

<pre><code>res = []
for x in range(5):
    if x % 2 == 0:
        for y in range(5):
            if y % 2 == 1:  
                res.append((x, y))
</code></pre>

<p>This is the expected result:</p>

<pre><code>[(0, 1), (0, 3), (2, 1), (2, 3), (4, 1), (4, 3)]
</code></pre>

<p>Here's the code I wrote, but it doesn't seem to work:</p>

<pre><code>list( map(( lambda x,y: (x,y)), filter((lambda x: x%2 == 0), range(5)), filter((lambda y: y%2 != 0), range(5))))
</code></pre>

<p>You don't even need map and filter, you could do the whole thing in a list comprehension</p>

<pre><code>[(x,y) for x in range(5) for y in range(5) if not x%2 and y%2]
</code></pre>

python dictionary filter functional-programming