[Tutor] String slicing from tuple list

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Thu Jul 21 21:58:22 CEST 2005



On 21 Jul 2005 cgw501 at york.ac.uk wrote:


> [(1423, 2637),(6457, 8345),(9086, 10100),(12304, 15666)]
>
> 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.

Hi Chris,

You can simplify the problem a bit by breaking it into smaller pieces.


Given a list, such as:

    [(1423, 2637),(6457, 8345),(9086, 10100),(12304, 15666)]

can you write a function that takes that, and produces a new list of the
in-betweens?

    [(2637, 6457), (8345, 9086), (10100, 12304)]


Good luck!



More information about the Tutor mailing list