As described in the title I'm trying to assign a dictionary with lists as values that are random to parent dictionary. An unexpected thing is that when I want to assign it to parent dictionary then I only get the latest dictionary assigned. Please see code example:
temp = {}
d = {}
for x in range(3):
for i in range(3):
temp[i] = list(np.random.randint(10, size=10))
print(x)
print(temp)
d[x] = temp
print(d[x])
print("--------------------------")
print("The final dictionary: ", d)
0
{0: [1, 4, 1, 7, 3, 9, 3, 8, 1, 5], 1: [6, 5, 2, 0, 5, 0, 5, 9, 7, 1], 2: [7, 9, 3, 3, 5, 8, 6, 0, 6, 0]}
{0: [1, 4, 1, 7, 3, 9, 3, 8, 1, 5], 1: [6, 5, 2, 0, 5, 0, 5, 9, 7, 1], 2: [7, 9, 3, 3, 5, 8, 6, 0, 6, 0]}
1
{0: [0, 0, 7, 0, 0, 1, 9, 9, 2, 0], 1: [1, 5, 8, 7, 2, 9, 0, 8, 7, 9], 2: [8, 8, 4, 8, 1, 1, 1, 2, 4, 4]}
{0: [0, 0, 7, 0, 0, 1, 9, 9, 2, 0], 1: [1, 5, 8, 7, 2, 9, 0, 8, 7, 9], 2: [8, 8, 4, 8, 1, 1, 1, 2, 4, 4]}
2
{0: [5, 4, 7, 1, 1, 3, 0, 3, 6, 9], 1: [5, 9, 7, 8, 0, 7, 1, 7, 6, 9], 2: [4, 2, 6, 1, 3, 7, 2, 6, 4, 8]}
{0: [5, 4, 7, 1, 1, 3, 0, 3, 6, 9], 1: [5, 9, 7, 8, 0, 7, 1, 7, 6, 9], 2: [4, 2, 6, 1, 3, 7, 2, 6, 4, 8]}
--------------------------
The final dictionary: {0: {0: [5, 4, 7, 1, 1, 3, 0, 3, 6, 9], 1: [5, 9, 7, 8, 0, 7, 1, 7, 6, 9], 2: [4, 2, 6, 1, 3, 7, 2, 6, 4, 8]}, 1: {0: [5, 4, 7, 1, 1, 3, 0, 3, 6, 9], 1: [5, 9, 7, 8, 0, 7, 1, 7, 6, 9], 2: [4, 2, 6, 1, 3, 7, 2, 6, 4, 8]}, 2: {0: [5, 4, 7, 1, 1, 3, 0, 3, 6, 9], 1: [5, 9, 7, 8, 0, 7, 1, 7, 6, 9], 2: [4, 2, 6, 1, 3, 7, 2, 6, 4, 8]}}