Move if to the end. See Writing Python Documents in List Views .
>>> [i for i in range(2) if i!=0] # Or [i for i in range(2) if i] [1]
If you were looking for a conditional expression, you could do something like @Martijn,
>>> [i if i!=0 else -1 for i in range(2)] [-1, 1]
If you need null objects, you can also filter(...) your list.
>>> filter(None, [1, 2, 0, 0, 4, 5, 6]) [1, 2, 4, 5, 6]
source share