I was trying to assign values to multi dimension list in python after initializing it to zeroes first. Following is the code where edge_strength and initialProb are multiD list.
edge_strength = [[1,2,3],[3,4,5],[6,7,8]]
initialProb = [[0]*3]*3
initialColumn =1
denominator = 10
for r in range(0,3):
initialProb[r][initialColumn] = float(edge_strength[r][initialColumn])/denominator
print initialProb
But when I finished and printed initialProb list, I got answer as - [[0, 0.7, 0], [0, 0.7, 0], [0, 0.7, 0]] Instead it should've been - [[0, 0.2, 0], [0, 0.4, 0], [0, 0.7, 0]].
Can anyone explain me this strange behaviour and the workaround?