On Fri, Jun 8, 2012 at 10:43 AM, Emile van Sebille 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)]
--
http://mail.python.org/mailman/listinfo/p
On 6/8/2012 9:17 AM Daniel Urban said...
On Fri, Jun 8, 2012 at 6:10 PM, Julio Sergio wrote:
> From a sequence of numbers, I'm trying to get a list that does something to
even
numbers but leaves untouched the odd ones, say:
[0,1,2,3,4,...] ==> [100,1,102,3,104,...]
I know that this can be d
On Fri, Jun 8, 2012 at 6:10 PM, Julio Sergio wrote:
> >From a sequence of numbers, I'm trying to get a list that does something to
> >even
> numbers but leaves untouched the odd ones, say:
>
> [0,1,2,3,4,...] ==> [100,1,102,3,104,...]
>
> I know that this can be done with an auxiliary function, a
>From a sequence of numbers, I'm trying to get a list that does something to
>even
numbers but leaves untouched the odd ones, say:
[0,1,2,3,4,...] ==> [100,1,102,3,104,...]
I know that this can be done with an auxiliary function, as follows:
->>> def filter(n):
... if (n%2 == 0):
...