"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
___
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
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
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