How about:

>>> [pow(2,x) for x in [1,2,3,4]]

[2, 4, 8, 16]


On 2/14/06, Michael Broe <[EMAIL PROTECTED]> wrote:
I read somewhere that the function 'map' might one day be deprecated
in favor of list comprehensions.

But I can't see a way to do this in a list comprehension:

>>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4])
[2, 4, 8, 16]

Is there a way?

Cheers,
Mike
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to