List Comprehension with If and Else Statement
It is fairly common to find list comprehension examples with a single if statement. However, you can have multiple evaluations
Example
Given a list of numbers, perform a list comprehension such that all even numbers are squares and all odd numbers remain the same.
sample_list = [ 1, 2, 3, 4, 5, 6 ]
[ x**2 if x%2 == 0 else x for x in sample_list ]