Last active
September 4, 2016 15:33
-
-
Save tfc/9fe122978bb8f7b8cefc509b3dbb5cdf to your computer and use it in GitHub Desktop.
Trivial python generator example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
odd_squares = [] | |
for x in range(0, 19): | |
if x % 2 == 1: | |
odd_squares.append(x * x) | |
print(odd_squares) | |
# same in one line: | |
print([x * x for x in range(0, 19) if x % 2 == 1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment