If logo comprehensions: if

1 2 3 4 5 6 7 8 9

There are two ways of using an if-statement in a comprehension. You can filter via:

[i for i in range(16) if i % 2 == 0]

Alternatively you can also use an if to calculate values:

[i if i % 2 == 0 else i * 2 for i in range(16)]

You can also combine the two approaches.

[i if i % 2 == 0 else i * 2 for i in range(16) if i % 3 == 0]

Before copying/pasting, try to predict what the last line of code does.