unlike with generatorsthis yield function looks like it' supposed to return value and assign it to variable this isin factexactly what' happening the coroutine is still paused at the yield statement and waiting to be activated again by another call to next(or ratheras you see in the interactive sessiona call to method called send(the send(method does exactly the same thing as next(except that in addition to advancing the generator to the next yield statement it also allows you to pass in value from outside the generator this value is assigned to the left side of the yield statement the thing that is really confusing for many people is the order in which this happensyield occurs and the generator pauses send(occurs from outside the function and the generator wakes up the value sent in is assigned to the left side of the yield statement the generator continues processing until it encounters another yield statement soin this particular exampleafter we construct the coroutine and advance it to the yield statement with call to next()each successive call to send(passes value into the coroutinewhich adds this value to its scoregoes back to the top of the while loopand keeps processing until it hits the yield statement the yield statement returns valueand this value becomes the return value of the most recent call to send don' miss thatthe send(method does not just submit value to the generatorit also returns the value from the upcoming yield statementjust like next(this is how we define the difference between generator and coroutinea generator only produces valueswhile coroutine can also consume them the behavior and syntax of next( ) __next__()and send(valueare rather unintuitive and frustrating the first is normal functionthe second is special methodand the last is normal method but all three do the same thingadvance the generator until it yields value and pause furtherthe next(function and associated method can be replicated by calling send(nonethere is value to having two different method names heresince it helps the reader of our code easily see whether they are interacting with coroutine or generator just find the fact that in one case it' function call and in the other it' normal method somewhat irritating