Python ProgrammingPython Programming

Append a dictionary to a list in a loop Python

alist = []

for x in range(10):
    adict = {1: x}
    alist.append(adict)
print(alist)
Output
[{1: 0}, {1: 1}, {1: 2}, {1: 3}, {1: 4}, {1: 5}, {1: 6}, {1: 7}, {1: 8}, {1: 9}]