the PHP ternary operator equivalent on Python

bonono at bonono at
Wed Nov 23 16:37:21 CET 2005

Luis M. Gonzalez wrote:
> This could be done easier this way:
> L = [('even','odd')[n%2] for n in range(8)]

That is even/odd, his(created to demonstrate the uglies of ternary) has
4 states, zero, -/+ then even/odd.

More information about the Python-list mailing list