yield from, and send

yield from it yields every item of it, one by one. It is shorthand for for x in it: yield x. It shines in recursive generators: walking a tree or a nested list, each call yields its own items and yield from the results of the calls on its children.

Generators can also receive values. gen.send(value) resumes the generator, and value becomes the result of the yield expression inside it. You must start the generator with next(gen) first, to run it to its first yield.

send is rare in everyday code. It was the basis of early coroutines, before async and await, which you will meet in the concurrency chapter. Knowing that it exists, and what it does, is enough for interviews.

Run it, then send a few more numbers to averager.