Can I do this with list comprehension?

Cliff Wells cliff at develix.com
Wed Aug 23 00:29:51 EDT 2006


On Tue, 2006-08-22 at 21:07 -0700, barberomarcelo at gmail.com wrote:
> b = [2, 4, 6, 8, 10, 12]

>>> a = [0, 1, 0, 1, 1, 0]
>>> b = [2, 4, 6, 8, 10, 12]
>>> [ j for i, j in zip ( a, b ) if i ]
[4, 8, 10]


-- 




More information about the Python-list mailing list