[Tutor] String slicing from tuple list
cgw501 at york.ac.uk
Thu Jul 21 21:39:36 CEST 2005
I have a list of tuples like this:
[(1423, 2637),(6457, 8345),(9086, 10100),(12304, 15666)]
Each tuple references coordinates of a big long string and they are in the
'right' order, i.e. earliest coordinate first within each tuple, and
eearliest tuple first in the list. What I want to do is use this list of
coordinates to retrieve the parts of the string *between* each tuple. So in
my example I would want the slices [2367:6457], [8345:9086] and
[10100:12304]. Hope this is clear.
I'm coming up short of ideas of how to achieve this. I guess a for loop,
but I'm not sure how I can index *the next item* in the list, if that makes
sense, or perhaps there is another way.
Any help, as ever, appreciated.
More information about the Tutor