How can I raise the numbers in list to a certain power?
Nobody has mentioned map and functools.partial and the accepted answer does not mention pow, but for the sake of completeness I am posting this solution:
import functools
bases = numbers = [1,2,3]
power = exponent = 3
cubed = list(map(functools.partial(pow, exponent), numbers))
I would use a list comprehension myself as suggested, but I think functools.partial is a very cool function that deserves to be shared. I stole my answer from @sven-marnach here by the way.