... continued

Continues the discussion on sending and receiving data from generators.

We'll cover the following...

Before we end our discussion on generators and the yield statement, let's see another way it can be used. In the example from the previous section, we used two yield statements to send and receive data in and out of the generator. We can instead use a single one to do both and without the need to do noop operations. The generator method to do this appears below:

def generate_numbers():
    i = 0

    while True:
   
...