Alternative list-comprehension
<p>I came across a question were someone wanted to generate <code>list3 = [1, 0, 1, 0, 0]</code> for <code>list1 = [0, 1, 0, 0, 1</code>] and <code>list2 = [0, 1, 0, 1, 1]</code>. </p>

<p>If one would <code>zip(list1, list2)</code> therefore only <code>zip(0, 0)</code> would generate <code>1</code> for <code>list3</code>.</p>

<p>I want to express the subsequent code by a list comprehension:</p>

<pre><code>L3 = []
for x in zip(L1, L2):
    if sum(x) == 0:
        L3.append(1)
    else:
        L3.append(0)
print L3 
</code></pre>

<p>I can get the same output by using this list comprehension:</p>

<pre><code>print [int(sum(x)==0) for x in zip(L1, L2)]
</code></pre>

<p>I would like to know if there is a way to express the if/else condition of the initial code block in a list comprehension more literally. I can understand this question might be considered superfluous as the if/else condition naturally is comprised, but alternatives posted could be very useful to me. </p>