bearophileh...@lycos.com wrote:
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

Thanks bearophile and John for your quick answers.
Unfortunately, the int that can replace a sublist can be > 255, but John's answer looks simple and good enough for me. I will use it as a starting point.

Thank's again.

--
Matthias Gallé
Project Symbiose
Centre de Recherche INRIA Rennes - Bretagne Atlantique,
Campus de Beaulieu, 35042 Rennes cedex, France
tel: (33|0) 2 9984 7523
http://www.irisa.fr/symbiose/matthias_galle
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to