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><code>a</code> and <code>b</code> are strings, they will be rightly treated as <em>iterables</em> by <code>map</code>, not constants as you intend. You should either use a list comprehension or not pass <code>a</code> and <code>b</code> as parameters to <code>map</code>:</p>

<pre><code>&gt;&gt;&gt; [a &lt; x &lt; b for x in mod_add]
[False, True, True]
</code></pre>

<p>Comparisons can be chained arbitrarily, so <code>(a &lt; x) and (x &lt; b)</code> can be replaced with <code>a &lt; x &lt; b</code></p>

<hr>

<p>Comparing integers instead of strings (which is probably what you want) is just another step away:</p>

<pre><code>&gt;&gt;&gt; [int(a) &lt; int(i) &lt; int(b) for i in mod_add]
[False, True, True]
</code></pre>

python python-3.x