DEV Community

Discussion on: Things that weren't so obvious when you started to program in Python

Collapse
 
danielz_ profile image
DanBot5K

To add to this, the output of the range function is a generator which generates values on the fly as opposed to having them stored in memory all at once.

Furthermore, if you replace the square brackets of a list comprehension with curved brackets, you get a generator comprehension.