First think about the steps you need to take to do this. Obviously your function is going to need to have a variable to hold the list you are supposed to return so an empty list is good for that.
Now you need to take each value from the first list or bases
and raise it to each value in the second list or exponents
, than add this value to your new list. Sounds like a good time for a double for
loop to me, or a for
loop within a for
loop.
but that’s what im doing im appending the data I get from the new_lst into exponent_lst.
I don’t think this is neccesarily a good condition to use zip()
.
I recommend looking at what your new_lst
contains. Try using a print()
to see what the values you are using actually are.
Inside your for
loop for example, what are i[0]
and i[i]
. Remember that every element in the first list need to be raised to every element in the second list.
it prints [(2,1), (3,2), (4,3)]
which is what I think the question is asking for because I multiply the base to power after that
Okay, from what your looking at, your aproach is spot on. However you need to raise every element in the first list by every element in the second list.
So for the lists [2, 3, 4]
and [1, 2, 3]
, you need to get the value of 2 to the power of 1, then 2 to the power of 2, than 2 to the power of 3, and then do the same for the second and third elements in the first list.
[2, 3, 4] [1, 2, 3] [2, 3, 4] [1, 2, 3] [2, 3, 4] [1, 2, 3]
^ ^ ^ ^ ^ ^
2 to the first 2 to the second 2 to the third
[2, 3, 4] [1, 2, 3] [2, 3, 4] [1, 2, 3] [2, 3, 4] [1, 2, 3]
^ ^ ^ ^ ^ ^
3 to the first 3 to the second 3 to the third
[2, 3, 4] [1, 2, 3] [2, 3, 4] [1, 2, 3] [2, 3, 4] [1, 2, 3]
^ ^ ^ ^ ^ ^
4 to the first 4 to the second 4 to the third
That’s why I think you probably need two for
loops. One to go through each value in the first list, and the other to go through each value in the the second list.
oooh I see that’s how you get 9 indexs from 3 indexs copy thanks