Q:

Raising elements of a list to powers indicated in another list

I need to raise my list [23, 43, 32, 27, 11] to the powers indicated in this list [3, 5, 4, 3, 2].
Meanding the 23 should be raised to the power of 3, 43 to the power of 5 etc...
I can do the whole list to one power with the help of this question: Raising elements of a list to a power but not like how I need.
Should I use two loops? Many thanks for the help.

A:

You could use zip():
>>> a = [23, 43, 32, 27, 11]
>>> b = [3, 5, 4, 3, 2]
>>> c = [x**y for x, y in zip(a, b)]
>>> c
[12167, 147008443, 1048576, 19683, 121]

or map() and operator.pow():
>>> from operator import pow
>>> d = list(map(pow, a, b))
>>> d
[12167, 147008443, 1048576, 19683, 121]

