Some questions about python list element and list comprehensions
<p>Come straight to the point. A list e.g. <code>lst = [1, 1, 1, 0, 0, 0]</code>, now I want to change 1 into 0 as <code>lst = [0, 0, 0, 0, 0, 0]</code>. </p>

<p>My original solution likes below:</p>

<pre><code>for item in lst:

    if item == 1:

        item = 0
</code></pre>

<p>Actually, the result list is still lst = [1, 1, 1, 0, 0, 0]. </p>

<p><strong>Q1</strong>: Is there any other solutions to solve it besides using list comprehension?</p>

<p><strong>Q2</strong>: How to write correct list comprehensions when many more <code>if else for</code> in it? So I have tried four styles below:</p>

<pre><code>No.1 lst = [0 if item == 1 for item in lst] # Returns syntax error

No.2 lst = [0 for item in lst if item == 1] # Returns [0, 0, 0]

No.3 lst = [0 if item == 1 else item for item in lst] # Returns [0, 0, 0, 0, 0, 0]

No.4 lst = [0 for item in lst if item == 1 else item] # Returns syntax error
</code></pre>
