So I started building a function with which I aim to correct the first 3 'allocations' which exceed a certain limit.
Below function now returns a list with the exceeded values per value in the passed list.
def correct_wrong_allocations_zw(weight_vect):
temp_weight_vect = list(weight_vect[:3])
limits = [1.00, 0.30, 0.25]
too_much_list = []
too_much = 0.00
for i in range(0, len(temp_weight_vect)):
if temp_weight_vect[i] > limits[i]:
too_much_list.append(temp_weight_vect[i]-limits[i])
return too_much_list
allocations = [0.10, 0.40, 0.50, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00]
allocations = correct_wrong_allocations_zw(allocations)
print allocations
The difference between allocations[1] and limits[1] is 0.10, yet the result of this program is:
[0.10000000000000003, 0.25]
What is going on?