how to use list compreshesnion if code example
Example 1: if else in list comprehension
[f(x) if condition else g(x) for x in sequence]
Example 2: list comprehension
[expression for item in list]
[f(x) if condition else g(x) for x in sequence]
[expression for item in list]