This is stumping me. This is a very simplified version of my code but exhibiting the exact issue:
test={"number":"0"}
testarray=[test]
print(testarray)
for x in range(5):
test["number"] = x
print(test)
testarray.append(test)
print("TestArray")
for x in testarray:
print(x)
The output is:
[{'number': '0'}]
{'number': 0}
{'number': 1}
{'number': 2}
{'number': 3}
{'number': 4}
TestArray
{'number': 4}
{'number': 4}
{'number': 4}
{'number': 4}
{'number': 4}
{'number': 4}
Why are all the entries set to the last value of the dictionary? I've also tried testarray.insert(len(testarray),test)
with the same result.