-
-
Save DugalMcCrow/26dbc538eb5165a79c2a925447ff1aec to your computer and use it in GitHub Desktop.
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
>>> # Create a list for subsequent operations | |
>>> numbers = [1, 2, 3, 4, 5, 6] | |
>>> | |
>>> # Typical way to create a list consisting of squares | |
>>> squares0 = [] | |
>>> for number in numbers: | |
... squares0.append(number*number) | |
... | |
>>> # List comprehensions | |
>>> squares1 = [number*number for number in numbers] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment