Can I do this with list comprehension?
Ben Finney
bignose+hates-spam at benfinney.id.au
Wed Aug 23 01:31:04 EDT 2006
barberomarcelo at gmail.com writes:
> 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?
What have you already tried, and how is it insufficient?
--
\ "Unix is an operating system, OS/2 is half an operating system, |
`\ Windows is a shell, and DOS is a boot partition virus." -- |
_o__) Peter H. Coffin |
Ben Finney
More information about the Python-list
mailing list