Why are list comprehensions written differently if you use `else`?
The following list comprehension worked when I tried it:
[num for num in hand if num != 11]
But this doesn't work:
[num for num in hand if num != 11 else 22]
which led me to believe that you can't use else in a list comprehension. However, it seems that you can, but it has to be written differently. This works:
[num if num != 11 else 22 for num in hand]
Why does the
if need to be placed earlier in the comprehension if you use
else with it?