The following code works in Python
var=range(20)
var_even = [0 if x%2==0 else x for x in var]
print var,var_even
However, I thought that the conditions need to be put in the end of a list. If I make the code
var_even = [0 if x%2==0 for x in var]
Then it won't work. Is there a reason for this?