def mainCall(nodeGroup):
maxScore = -9999999
maxPart = []
tempPartition = []
tempScore = 0.0
for j in range(2, 1+nodes/2):
nodeGroup = cho
When you say
maxPart = tempPartition
you are not creating a copy of tempPartition
but you are making the maxPart
also to point to the same list that tempPartition
points to. To really make a copy, you can use slicing notation like this
maxPart[:] = tempPartition
or
maxPart = tempPartition[:]
The difference between maxPart[:] = tempPartition
and maxPart = tempPartition[:]
is that the former mutates the maxPart
and copies all the values from tempPartition
to maxPart
and latter creates a new list with a copy of all the data in tempPartition
and makes the maxPart
points to the newly created list.