[omaha] This is the message I tried to send/post this morning

Burch Kealey bkealey at mail.unomaha.edu
Sat Dec 1 18:50:07 CET 2007


   I am thinking I have to create some sort of iterator to move through
   the first subscript I had tried various forms of list comprehension
   and things like append in my many failed attempts. I was sure that I
   could just say something like
   for each in data:
       field1=[data[1]]
   I assumed that by referencing each I was handling the record number
   (equivalent) and field1 is created as a list of single item lists
   The solution that you proposed is similar-it presumes the record
   number is handled by iterating through rec.  Why this works for [0]
   and not any other value??
   -----omaha-bounces at python.org wrote: -----

     To: [1]omaha at python.org
     From: Burch Kealey [2]<bkealey at mail.unomaha.edu>
     Sent by: [3]omaha-bounces at python.org
     Date: 12/01/2007 11:27AM
     Subject: Re: [omaha] This is the message I tried to send/post this
     morning
       sublist = []
       for rec in thedata:
          sublist.append(rec[1])
       Actually-this does not work-I am getting an index out of range
     error.
       When I change the subscript to 0 as in sublist.append(rec[0]) it
       works,  I get the first item from  each  item in  the list. when
     the
       subscript is anything but 0 I get an error message.

References

   1. mailto:omaha at python.org
   2. mailto:bkealey at mail.unomaha.edu
   3. mailto:omaha-bounces at python.org


More information about the Omaha mailing list