MemotivaGenerators and yield

What is a generator?

Generators and yield

Audio flashcard · 0:15

Nortren·

What is a generator?

0:15

A generator is a function that uses yield to produce values one at a time, instead of return to produce a single result. Calling a generator function does not run its body; it returns a generator object. Each call to next runs the function up to the next yield, then suspends.
docs.python.org