I'm trying to subtract sold stock from the total stock, however using this code, it subtracts each value in list B from each value in list A.
I want the corresponding value in list B to be subtracted from its corresponding value in list A, then move to the next set of numbers, opposed to subtracting every value from list B from each value in list A.
I am unsure how to modify my code, how do I achieve this?
for s in stocks:
for q in quantities:
print(float(s) - float(q))
what I want:
stock: [10, 20, 30]
quantities: [2, 3, 4]
output: 8, 17, 26
what is occurring:
stock: [10, 20, 30]
quantities: [2, 3, 4]
output: 8, 7, 6, 18, 17, 16, 28, 27, 26