list comprehension does not return empty list
<p>I tried to find the relevant question but couldn't find so creating a new one. 
My program creates a new list using list comprehension in python as per a simple if condition. </p>

<pre><code>  Newone = [ temp for temp in Oldone if temp % 2 != 0 ]
</code></pre>

<p>It works fine but when in some situation it doesn't work. For example this one </p>

<pre><code> Oldone = [1]
 Newone = [ temp for temp in Oldone if temp % 2 != 0 ]
</code></pre>

<p>This returns [1] but i am expecting Newone to be [] </p>

<pre><code> 1%2 == 1
</code></pre>

<p>So your your condition: <code>temp % 2 != 0</code> is <code>True</code>, therefore it is included in the list. If you want an empty list, you should change it <code>temp % 2 == 0</code>.</p>

python list condition list-comprehension