python list comprehension elif

>>> l = [1, 2, 3, 4, 5]
>>> ['yes' if v == 1 else 'no' if v == 2 else 'idle' for v in l]
['yes', 'no', 'idle', 'idle', 'idle']

Here is what the above code is Doing:
1. The first line is a list comprehension.
2. The first part of the list comprehension is the expression that is evaluated for each element in the list.
3. The second part of the list comprehension is the for loop that iterates over each element in the list.
4. The expression is evaluated for each element in the list.
5. If the expression evaluates to True, then ‘yes’ is added to the new list.
6. If the expression evaluates to False, then the next expression is evaluated.
7. If the second expression evaluates to True, then ‘no’ is added to the new list.
8. If the second expression evaluates to False, then ‘idle’ is added to the new list.
9. The new list is returned.