Raising elements of a list to a power
Another map
pattern, using lambda
instead of function.partial()
:
numbers=[1,2,3,4]
squares=list(map(lambda x:pow(x,2),numbers))
print(squares)
Use list comprehension:
def power(my_list):
return [ x**3 for x in my_list ]
https://docs.python.org/3.4/tutorial/datastructures.html#list-comprehensions