At Wednesday 23/8/2006 01:07, [EMAIL PROTECTED] wrote:
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]
print [belem for aelem,belem in zip(a,b) if aelem==1]
print [belem for i,belem in enumerate(b) if a[i]==1]
Or itertools.izip...
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
--
http://mail.python.org/mailman/listinfo/python-list