Re: remove all elements in a list with a particular value

2007-05-18 Thread Steven Howe
Steven Howe wrote: > MRAB wrote: >> On May 16, 4:21 pm, Lisa <[EMAIL PROTECTED]> >> wrote: >> >> I am reading in data from a text file. I want to enter each value on >> the line into a list and retain the order of the elements. The number >> of elements and spacing

Re: remove all elements in a list with a particular value

2007-05-17 Thread Steven Howe
MRAB wrote: On May 16, 4:21 pm, Lisa <[EMAIL PROTECTED]> wrote: I am reading in data from a text file. I want to enter each value on the line into a list and retain the order of the elements. The number of elements and spacing between them varies, but a typical line looks like: ' SRCPARA

Re: remove all elements in a list with a particular value

2007-05-17 Thread MRAB
On May 16, 4:21 pm, Lisa <[EMAIL PROTECTED]> wrote: > I am reading in data from a text file. I want to enter each value on > the line into a list and retain the order of the elements. The number > of elements and spacing between them varies, but a typical line looks > like: > > ' SRCPARAM 1 6

Re: remove all elements in a list with a particular value

2007-05-16 Thread James Stroud
John Zenger wrote: print [x for x in items if x != ''] > > ['SRCPARAM', '1', '6.35e-07', '15.00', '340.00', '1.10', '3.0'] > This can be shortened to [x for x in items if x] James -- http://mail.python.org/mailman/listinfo/python-list

Re: remove all elements in a list with a particular value

2007-05-16 Thread Lisa
Great. Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list

Re: remove all elements in a list with a particular value

2007-05-16 Thread John Zenger
7;', '1.10', '', '', '', '', '', '3.0', '', '', ''] > > And after the for loop I get: > ['SRCPARAM', '1', '6.35e-07', '15.00', '340.00',

Re: remove all elements in a list with a particular value

2007-05-16 Thread Larry Bates
Lisa wrote: > I am reading in data from a text file. I want to enter each value on > the line into a list and retain the order of the elements. The number > of elements and spacing between them varies, but a typical line looks > like: > > ' SRCPARAM 1 6.35e-07 15.00 340.00 1.10 3.0

remove all elements in a list with a particular value

2007-05-16 Thread Lisa
I am reading in data from a text file. I want to enter each value on the line into a list and retain the order of the elements. The number of elements and spacing between them varies, but a typical line looks like: ' SRCPARAM 1 6.35e-07 15.00 340.00 1.10 3.0 ' Why does the followi