Created
May 22, 2020 13:24
Star
You must be signed in to star a gist
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