find sublist inside list
mgalle at irisa.fr
Mon May 4 14:08:51 CEST 2009
My problem is to replace all occurrences of a sublist with a new element.
Given ['a','c','a','c','c','g','a','c'] I want to replace all
occurrences of ['a','c'] by 6 (result [6,6,'c','g',6]).
If I do this with string ('acaccgac') I have the advantage of all the
'find' functions, but perfomance is bad and some extra care must be
taken if one element consist of more then one character (case of 11 for
So I really would like to work with lists straightforward, but I could
not found anything to search a sublist inside a list.
Any propositions for a simple solution?
Thanks in advance,
Centre de Recherche INRIA Rennes - Bretagne Atlantique,
Campus de Beaulieu, 35042 Rennes cedex, France
tel: (33|0) 2 9984 7523
More information about the Python-list