Generator Expressions for On-the-Fly Generation in Python


Generate items on the fly using generator expressions.

Source Code

squared_gen = (x**2 for x in range(10))
for num in squared_gen:
    print(num)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments