[EMAIL PROTECTED] wrote: > Let's say I have two lists: > > a = [0, 1, 0, 1, 1, 0] > b = [2, 4, 6, 8, 10, 12] > > I want a list comprehension that has the elements in b where a[element] > == 1. > > That's to say, in the example above, the result must be: [4, 8, 10] > > Any hints?
>>> from itertools import izip >>> a = [0, 1, 0, 1, 1, 0] >>> b = [2, 4, 6, 8, 10, 12] >>> [y for x, y in izip(a, b) if x == 1] [4, 8, 10] -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Man is a hating rather than a loving animal. -- Rebecca West -- http://mail.python.org/mailman/listinfo/python-list