3
I have the following situation: - I have a variable called (vector_distances). This variable receives a 2D list with several vectors. - I wish it to be displayed, only vectors whose sum of their indices is less than 100. - I have the code below, but you are not doing what I need.
def funcao_fitness():
fitness = 0
i = 0
vetor_distancias = [[10,20,30,40],[50,60,70,80],[5,6,7,8],[100,200,300,400],[9,15,25,30]]
for i in vetor_distancias:
fitness = (fitness + i) if i <= 100
print (fitness[i])
return fitness
print (funcao_fitness())
Thanks for your help.
The sum of its indices or its values? ex: [1,2,3] = 6 certain?
– Miguel
Of their values. Ex. [1,2,3] = 6
– Danilo
the fitness will increase this sum if it is less than 100 certain?
– Miguel
Yes. Exactly.
– Danilo