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

John Washakie washakie at gmail.com
Tue May 1 12:10:14 CEST 2007


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 search for :s

Thanks!!


More information about the Tutor mailing list