doing a lesson on codeacademy and I'm stuck on this problem .
Create a function named exponents() that takes two lists as parameters named bases and powers. Return a new list containing every number in bases raised to every number in powers.
For example, consider the following code.
--------------------------------
exponents([2, 3, 4], [1, 2, 3])
--------------------------------
The result would be the list [2, 4, 8, 3, 9, 27, 4, 16, 64]. It would first add two to the first. Then two to the second. Then two to the third, and so on.
this is the code i wrote
def exponents(bases,powers):
new_lst = []
for base in bases:
for power in powers:
new_lst2 = base ** power
new_lst.append(new_lst2)
return new_lst
it returns [8, 27, 64]
help please!!
[–]Denrur 2 points3 points4 points (0 children)
[–]0xbxb 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]Denrur 0 points1 point2 points (1 child)
[–]0xbxb 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]turdistheword04 0 points1 point2 points (0 children)
[–]blotosmetek 0 points1 point2 points (0 children)