map() is returning only part of arguments
<p>I have the following code:</p>

<pre><code>a = '0'
b = '256'
mod_add = ['300', '129', '139']
list(map(lambda a, b, x: (a &lt; x) and (x &lt; b), a, b, mod_add))
</code></pre>

<p>I'd like to check every element in mod_add, but </p>

<pre><code>list(map(lambda a, b, x: (a &lt; x) and (x &lt; b), a, b, mod_add))
</code></pre>

<p>returns only one <code>False</code>.
With some values <code>(a = '100', b = '200')</code> it returns <code>'False', 'False', 'False'</code>.</p>

<p>What am I doing wrong?</p>

<p>This is really the kind of thing you should prefer list comprehensions for.</p>

<pre><code>min_, max_ = '0', '256'
# do you mean for these to be compared lexicographically?!
# be aware that '0' &lt; '1234567890' &lt; '256' is True

mod_add = ['300', '129', '139']

result = [min_ &lt; mod &lt; max_ for mod in mod_add]
# [False, True, True]
</code></pre>

<p><a href="https://docs.python.org/3/library/functions.html#map" rel="nofollow"><code>map</code></a> <a href="https://docs.python.org/3/library/functions.html#filter" rel="nofollow"><code>filter</code></a> and <a href="https://docs.python.org/2/library/functions.html#reduce" rel="nofollow"><code>reduce</code></a> (now <a href="https://docs.python.org/3/library/functools.html#functools.reduce" rel="nofollow"><code>functools.reduce</code></a>) are mighty tools to be sure, but Python tends to shy away from them in favor of more verbose, easier to read expressions.</p>

python python-3.x