Click here to Skip to main content
15,902,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Python
data = [  {"name":jon},{"name":dom} ]

root = [ {"age":30},{"age":55]]

// i want to add both them like this

final = [ {"name":jon , "age":30},
          {"name":dom , "age":55}   ]


What I have tried:

But I got error      
// 'set' object does not support item assignment
Posted
Updated 12-Aug-22 22:39pm

I think this[^] is what you're looking for!
 
Share this answer
 
You can make use of the Built-in Functions: zip() — Python 3.10.6 documentation[^]:
Python
data = [  {"name":"jon"},{"name":"dom"} ]

root = [ {"age":30},{"age":55}]
final = zip(data, root)
for item in final:
    print(item)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900