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
The if predicate comes after the specification of the for i in range(2) in a list comprehension. You can also have arbitrary number of ifs.
if
for i in range(2)