Re: [Tutor] if in an iteration, quick Q!!

2007-05-01 Thread Alan Gauld
"John Washakie" <[EMAIL PROTECTED]> wrote > Therefore I want to be able to say: > > a = [int(x) for x in tmp IF x in tmp] > x will always be in tmp - thats where it comes from! You want to check if its non null. a = [int(x) for x in tmp if x] Alan G ___

Re: [Tutor] if in an iteration, quick Q!!

2007-05-01 Thread John Washakie
Thanks > > Depending on what an 'empty' element is you may have to refine that. > I also noted, if I used: tmp = data[6].strip().split() rather than: tmp = data[6].strip().split(' ') I eliminated the 'empty' elements... ___ Tutor maillist - Tuto

Re: [Tutor] if in an iteration, quick Q!!

2007-05-01 Thread Kent Johnson
John Washakie wrote: > I can't recall how to do this: > > I want: > a = [int(x) for x in tmp] > > but, my tmp has some empty elements, so it fails... > > Therefore I want to be able to say: > > a = [int(x) for x in tmp IF x in tmp] That's almost right, except it checks the wrong thing. Try a

[Tutor] if in an iteration, quick Q!!

2007-05-01 Thread John Washakie
I can't recall how to do this: I want: a = [int(x) for x in tmp] but, my tmp has some empty elements, so it fails... Therefore I want to be able to say: a = [int(x) for x in tmp IF x in tmp] I know there's a way! Ive seen it before, but now cannot find it! 'if' is a pretty generic thing to se