This question is very much like: if/else in Python's list comprehension? and Simple syntax error in Python if else dict comprehension . But still i dont understand what error I make here:
[i if i!=0 for i in range(2)]
             ^
       syntax error
I only want the entries in the list that are non-zero for sparsity.
 
     
    