I am trying to divide values from two lists by each other, and I want to output a list with the quotients. The problem I am having is that all of the values are going through each other and dividing.
If I have two lists like this:
lst1 = [101, 2, 3]
lst2 = [69, 0, 0]
I want the output to look like this when I divide lst2[0]/lst1[0], lst2[1]/lst1[1], lst2[2]/lst1[2]:
output_lst = [0.6831683168316832, 0.0, 0.0]
My code looks like this, which gives me an output like this instead:
output_lst = [((x)/(y)) for x in lst2 for y in lst1]
print(output_lst)
#[0.6831683168316832, 34.5, 23.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
I've also tried this, which also gives me the same output:
for x in lst2:
for x in lst1:
output_lst = x/y
print(output_lst)
#[0.6831683168316832, 34.5, 23.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
I'm trying to avoid doing each calculation individually and then putting it all into a list. How can I just divide the values in order, with no values being repeatedly divided?
Where am I going wrong in my code? Would appreciate any help - thanks.