create list of dictionaries python loop code example
Example 1: python generate dictionary in loop
n = int(input())
ans = {i : i*i for i in range(1,n+1)}
print(ans)
Example 2: python loop through array of dictionaries
dataList = [{'a': 1}, {'b': 3}, {'c': 5}]
for index in range(len(dataList)):
for key in dataList[index]:
print(dataList[index][key])