list comprehension question

Bengt Richter bokr at oz.net
Mon Mar 25 16:55:31 EST 2002


On 25 Mar 2002 19:10:33 GMT, bokr at oz.net (Bengt Richter) wrote:
[...]
> >>> [x<2 and 1 or x<5 and 2 or x<9 and 3 or x<=11 and 4 for x in xrange(11)]
                                                ^--irrelevant
> [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4]
>

 >>> [x<2 and 1 or x<5 and 2 or x<9 and 3 or x<11 and 4 for x in xrange(11)]
 [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4]

That is aesthetically more pleasing. Sorry, couldn't leave it be. ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list