Indexing an array with a logical array of the same shape in Python
<p>I would like to be able to do:</p>

<pre><code>a = [1,2,3]
a[[True, True, False]]
&gt;&gt; array([1,2])
</code></pre>

<p>I just can't find the simple way how... Thanks!</p>

<p>You can use <code>zip</code> and list comprehension.</p>

<pre><code>a = [1,2,3]
b = [True, True, False]

c = [i for i,j in zip(a,b) if j]
</code></pre>

python