[Tutor] Indexing a List of Strings
Alan Gauld
alan.gauld at btinternet.com
Wed May 18 02:27:32 CEST 2011
"Spyros Charonis" <s.charonis at gmail.com> wrote
> for item in finalmotifs:
> for line in my_list:
> if item in line:
> print line.index(item)
>
> But this only returns a single number (e.g 119), which is the index
> at which
> my sequence begins.
>
> Is it possible to get a pair of indices that indicate beginning and
> end of
> substring?
print line.index(item)+len(item)
Presumably since its matching item the end index will be len(item)
characters later? Or am I missing something?
Alan G.
More information about the Tutor
mailing list