Created
July 2, 2021 11:56
-
-
Save thecraftman/f645f28dc9819595aa108ab9b32a05bf to your computer and use it in GitHub Desktop.
Python Generators from a list comprehension.
This file contains hidden or 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
# list comprehension | |
my_nums = (x*x for x in [1, 2, 3, 4, 5]) | |
print my_nums | |
for num in my_nums: | |
print num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment