Similar to this question, but instead of replacing one item with another, I\'d like to replace any occurrences of one item with the contents of a list.
orig
If you enumerate backwards, you can extend the list as you go because the items you move have already gone through the enumeration.
>>> orig = [ 'a', 'b', 'c', 'd', 'c' ]
>>> repl = [ 'x', 'y', 'z' ]
>>> desired = [ 'a', 'b', 'x', 'y', 'z', 'd', 'x', 'y', 'z' ]
>>> for i in xrange(len(orig)-1, -1, -1):
... if orig[i] == 'c':
... orig[i:i+1] = repl
...
>>> orig
['a', 'b', 'x', 'y', 'z', 'd', 'x', 'y', 'z']