I am trying to update a nested dictionary within a for loop, but the final output seems to over writing the previous key values.
a = {}
b = {}
f=0
for x in range(3):
a['test1'] = 1+f
a['test2'] = 2+f
a['test3'] = 3+f
f = f+1
b[f] = a
print(b)
Output:
{1: {'test1': 3, 'test2': 4, 'test3': 5}, 2: {'test1': 3, 'test2': 4, 'test3': 5}, 3: {'test1': 3, 'test2': 4, 'test3': 5}}
Expected Output:
{1: {'test1': 1, 'test2': 2, 'test3': 3}, 2: {'test1': 2, 'test2': 3, 'test3': 4}, 3: {'test1': 3, 'test2': 4, 'test3': 5}}