[Tutor] List manipulation
Bob Gailer
bgailer at alum.rpi.edu
Wed Sep 13 21:49:33 CEST 2006
Srinivas Iyyer wrote:
> Dear group:
>
> I have a data like this:
> 10 15
> 16 20
> 25 35
> 45 50
> 55 60
> 61 65
> 75 80
>
> Since 15 precedes 16, I want to consider 10:20 as one
> unit. If I repeat completely for data
>
> I would get:
> 10 20
> 25 35
> 45 50
> 55 65
> 75 80
>
> test = ['10\t15', '16\t20', '25\t35', '45\t50',
> '55\t60', '61\t65', '75\t80']
>
>
> I cannot think a way to do this in simple. Could
> members suggest some way to solve this please.
>
I assume by "precedes" you mean is one-less-than. To test this you
should convert the strings into integers. Since the numbers come in
pairs each pair must be split at the \t (using split), then convert each
number to integer (using int).
Hope that's enough to get you started.
--
Bob Gailer
510-978-4454
More information about the Tutor
mailing list