Extended List Comprehension
Joel Bender
jjb5 at cornell.edu
Fri Jan 20 16:37:51 EST 2006
> You could (in 2.5) use:
>
> [(x if x%2 else 'even') for x in '1234']
Or this:
[int(x)&1 and x or 'even' for x in '1234']
More information about the Python-list
mailing list