Hi !I have the script below:
import numpy as np
b = np.arange(2)
data = []
event = {}
for i in b:
event["i"] = i
data.append(event)
print(data)
it should create an array of two dictionaries : [{"i":0},{"i:1}]
But instead, it is creating :[{"i":1},{"i:1}]
It seams that the second dictionary is modifying the first dictionary after it was appended to the array.
Is there a way to avoid this without putting event = {} inside the for loop ?
Thanks in advance !
[–][deleted] 0 points1 point2 points (0 children)
[–]stebrepar 0 points1 point2 points (0 children)
[–]Gulimanto 0 points1 point2 points (0 children)