conditional condition list comprehension code example
Example 1: list comprehension python with condition
[f(x) if condition else g(x) for x in sequence]
Example 2: conditional list comprehension
obj = ["Even" if i%2==0 else "Odd" for i in range(10)]
print(obj)