I have a with dict with the following format
dic = {
'x':[1, 2, 3, 4],
'y':[2, 4, 5, 6],
'z':['a', 'b', 'c', 'g'],
'a':['d', 'e', 'f', 'a'],
}
I want to convert it to below format
lst_wth_dic = [
{'x':1, 'y':2, 'z': 'a', 'a':'d'},
{'x':2, 'y':4, 'z':'b', 'a':'e'},
{'x':3, 'y':5, 'z':'c', 'a': 'f'},
{'x':4, 'y':6, 'z':'g', 'a': 'a'}
]
What I have tried so far is this
import copy
lst_wth_dic = []
b = {}
for key, val in dic.items():
for item in val:
b[key] = item
c = copy.copy(b)
lst_wth_dic.append(c)
It does not achive the desired output that i require.