About a list comprehension to transform an input list

Ian Kelly ian.g.kelly at gmail.com
Fri Jun 8 13:10:42 EDT 2012


On Fri, Jun 8, 2012 at 10:43 AM, Emile van Sebille <emile at fenx.com> wrote:
> Or alternately by leveraging true/false as 1/0:
>
>>>> [ 100*(not(ii%2))+ii for ii in range(10)]

The same thing, leaving bools out of it altogether:

>>> [100*(1-ii%2)+ii for ii in range(10)]



More information about the Python-list mailing list