first_obj= [{"name":"sat","age":20}]
second_obj = [{"country":'India'}]
How to add array of dictionary in python?
third_obj = [{"name":'sat',"age":20,"country":'India'}]
first_obj= [{"name":"sat","age":20}]
second_obj = [{"country":'India'}]
How to add array of dictionary in python?
third_obj = [{"name":'sat',"age":20,"country":'India'}]
first_obj= [{"name":"sat","age":20}]
second_obj = [{"country":'India'}]
third_obj = [{**first_obj[0], **second_obj[0]}]
print(third_obj)
Output
[{'name': 'sat', 'country': 'India', 'age': 20}]
Assuming both objects will always have the same length, you can iterate both lists and merge the dictionaries:
third_obj = []
for a, b in zip(first_obj, second_obj):
combined_dict = dict(a.items() + b.items()) # merge dictionaries
third_obj.append(combined_dict)