Skip to content

Instantly share code, notes, and snippets.

@tfc
Last active September 4, 2016 15:33
Show Gist options
  • Save tfc/9fe122978bb8f7b8cefc509b3dbb5cdf to your computer and use it in GitHub Desktop.
Save tfc/9fe122978bb8f7b8cefc509b3dbb5cdf to your computer and use it in GitHub Desktop.
Trivial python generator example
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