BeginnerCoder

Lesson 24 — Generators that receive

Two-way generators

A generator can receive values with send(): x = yield total pauses, and when the caller sends a value it lands in x.

Why it matters: it models pipelines and cooperative tasks.

Want it another way?
Task

Add each received value to total so the running total prints 10, then 15.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with Python Intermediate

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.