I created a dictionary, where the key is a tuple of 3 elements and the value is a list, as so:
dic = {}
l = []
for z in range(0,20):
for y in range(0,150):
for x in range(0,200):
for j in range(0,4):
l.append(self.images[j].GetScalarComponentAsDouble(x, y, z, 0))
dic.update({(x,y,z) : l})
print(dic[(25,25,5)])
images
is just a list of image data, from where I get the intensity value and store this value in list l
.
The final result I want to see in the dictionary will have items in this form:
{(...),
(150,120,10): [2,5,3,9],
(130,100,16): [4,1,1,8],
(...)}
But because the list is always being appended with elements without being reseted, I cannot obtain this result.
How can I reset the list l
so that every tuple key has its own list value?