I would like to merge two dictionaries this way below:
dict1={
'kl':'ngt',
'schemas':
[
{
'date':'14-12-2022',
'name':'kolo'
}
]
}
dict2={
'kl':'mlk',
'schemas':
[
{
'date':'14-12-2022',
'name':'maka'
}
],
}
then I create a variable that will group the two dictionaries in this way
all_dict=[
'kl':'ngt',
'schemas':
[
{
'date':'14-12-2022',
'name':'kolo'
}
],
'kl':'mlk',
'schemas':
[
{
'date':'23-10-2022',
'name':'maka'
}
]
......
]
How to get this result. I'm stuck right now please help me if possible
CodePudding user response:
maybe the result structure that you want is like this:
all_dict=[
{
'kl':'ngt',
'schemas':
[
{
'date':'14-12-2022',
'name':'kolo'
}
],
},
{
'kl':'mlk',
'schemas':
[
{
'date':'23-10-2022',
'name':'maka'
}
]
}
......
]
so to get this result should only do this:
all_dict = [dict1, dict2]
or
all_dict = []
all_dict.append(dict1)
all_dict.append(dict2)
CodePudding user response:
Your expected result is a dictionary with two keys with the same string "schemas". That's not possible.