DEV Community

Discussion on: A Short Guide to Python Comprehensions

Collapse
 
catriel profile image
Catriel Lopez

Great post! You can also create a generator by comprehension:

sum(i * i for i in range(100))

for example! You can surround it with parentheses if you want. It's great for heavy operations when you don't need the entire data structure to be generated.

Collapse
 
highflyer910 profile image
Thea

Thank you for adding this! Exploring this now, and this is another great feature😊