def feed(consumer, iterable):
    """feed(consumer, iterable) -> yield items

    Helper function to send elements from an iterable into a coroutine.

    >>> def counter():              # Count the items sent in.
    ...     c = 0
    ...     _ = (yield None)        # Start the coroutine.
    ...     while True:
    ...             c += 1
    ...             _ = (yield c)   # Accept a value sent into the coroutine.
    ... 
    >>> cr = counter()
    >>> cr.send(None)  # Prime the coroutine.
    >>> list(feed(cr, ["spam", "ham", "eggs"]))  # Send many values.
    [1, 2, 3]
    >>> cr.send("spam and eggs")  # Manually sending works too.
    4

    """
    for obj in iterable:
        yield consumer.send(obj)
