I have question about list comprehension. If I want to output the odd squared numbers and put the condition in the output part (I know how to put condition in the loop part to get the desired result)
[num**2 if num % 2==0 for num in range(10)]
returned an error code. Why Python doesn't like it?
By adding else, the following returns zeros
[num**2 if num % 2==0 else 0 for num in range(10)]
so I tried to remove zeros on top of this
[num**2 if num % 2==0 else 0 for num in range(10)].remove(0)
and python returned empty, why?