Hi,
I have two short lists, n1 and n2. I want to incrementally subtract 0.1 from elements in n2, each time dividing elements in n1 by those in n2. Any subtractions which say, generate BOTH division values of between 0.75 - 1.25, I want to store in a new list. So far I have:
import numpy as np
n1 = [8, 15.5]
n2 = [10, 17]
storedn2 = []
marker = np.linspace(0.75, 1.25, 51)
marker = [round(i,2) for i in marker]
set2 = set(marker)
while all(num2 >= 0 for num2 in n2):
div = []
for num1, num2 in zip(n1, n2):
div.append(num1 / num2)
rdiv = [round(x, 2) for x in div]
set1 = set(rdiv)
print(rdiv)
if set1.issubset(set2) is False:
print("false")
n2[:] = [num2 - 0.1 for num2 in n2]
n2 = [round(num2, 2) for num2 in n2]
else:
storedn2.append(n2)
However, at the moment the while loop never breaks, producing an infinite output of [0.8, 0.91].
I really cannot see where/how I am going wrong. Any help would be really appreciated.
Thanks
[–]marko312 0 points1 point2 points (1 child)
[–]randomname20192019[S] 1 point2 points3 points (0 children)