[Tutor] accessing string in list

Bryan Fodness bryan.fodness at gmail.com
Tue Jul 15 16:55:44 CEST 2008

I have a list of labels for a data file,

test = ['depth', '4', '6', '10', '15', '20', '30', '40', 'angle']

I would like to get the string of the first value that is greater than a
known value and the previous string.

If I have 15.8, I would like to get the index of '20' and '15'.  I would
also like to make sure that my known value falls in the range 4-40.

I am having trouble with the mixed types.

for i in range(len(test)):
    if Field < int(test[i]):
        print i
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080715/7571575b/attachment.htm>

More information about the Tutor mailing list