How can I use an if-else condition inside a list comprehension to overwrite an existing list?
<p>I'm trying to multiply numbers greater than 3 by two, and subtract one from everything else. However, nothing happens to the list.
This is my code:</p>

<pre><code>lst = [1,2,3,4,5,6,7,8,9,10]

print (lst)

[x*2 if x &gt; 3 else x-1 for x in lst]     

print (lst)
</code></pre>

<p>Why aren't the contents of the <em>lst</em> variable modified by the list comprehension?</p>

<p>You didnt re-assigned it to the variable name.</p>

<pre><code>lst = [1,2,3,4,5,6,7,8,9,10]

print (lst)

lst = [x*2 if x &gt; 3 else x-1 for x in lst]

print (lst)
</code></pre>

python list-comprehension in-place