John O'Hagan:
> li=['a', 'c', 'a', 'c', 'c', 'g', 'a', 'c']
> for i  in range(len(li)):
>     if li[i:i + 2] == ['a', 'c']:
>         li[i:i + 2] = ['6']

Oh well, I have done a mistake, it seems.
Another solution then:

>>> 'acaccgac'.replace("ac", chr(6))
'\x06\x06cg\x06'

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to