Rita Sue and Bob too

Jeffrey Froman Jeffrey at Fro.man
Fri Aug 20 01:03:59 EDT 2004


Jeffrey Froman wrote:
> How about a generator?

Sorry, bad paste on my previous reply. The generator example should look
like:

def replace_in_list(apple, worm, new_worm):
    while apple:
        if worm == apple[:len(worm)]:
            apple = apple[len(worm):]
            for w in new_worm:
                yield w
        else:
            yield apple.pop(0)






More information about the Python-list mailing list