[Tutor] parsing an array

sith . sith618 at yahoo.com
Thu Nov 15 08:07:43 CET 2007


a = [[1,2],[3,1.5],[5,6]]
  for i in a:
    print i
    if i[1]>i[0]:
        print "second index is larger"
    else:
        print "second index is smaller"
  [1, 2]
  second index is larger
  [3, 1.5]
  second index is small
er
[5, 6]
  second index is larger
  
What I'd like do is compare if 1.5 in i[1] is greater than 2 in i[0]; 
for time series, t(1)>t(0) and interate through the entire list - is 6 in i[2]>than 1.5 in i[1] etc?
Since the data is in columns in a text file or csv, I can't put 1.5 in the same sublist as 2, and 6 in the same sublist as 1.5 to make things easier.  What can I do?  
Thank you for your help.

       
---------------------------------
Get easy, one-click access to your favorites.  Make Yahoo! your homepage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071114/2eb2406f/attachment-0001.htm 


More information about the Tutor mailing list