squares, twos, odds
Let us show you some other list comprehension examples:
Example #1:
The snippet produces a ten-element list filled with squares of ten integer numbers starting from zero (0, 1, 4, 9, 16, 25, 36, 49, 64, 81)
Example #2:
The snippet creates an eight-element array containing the first eight powers of two (1, 2, 4, 8, 16, 32, 64, 128)
Example #3:
The snippet makes a list with only the odd elements of the squares list.
Last updated