-1

Suppose I have two list of lists as follows:

List1=[[1,2],[3,4],[3,8]]

List2=[[1.2,2.4],[2.4,5.0],[4.5,6.0]]

How would I get the above as:

List3 = [{1:1.2,2:2.4},{3:2.4,4:5.0},{3:4.5,8:6.0}]
Ch3steR
  • 20,090
  • 4
  • 28
  • 58

2 Answers2

0

Try this:

List3 = [dict(zip(*lsts)) for lsts in zip(List1, List2)]
Riccardo Bucco
  • 13,980
  • 4
  • 22
  • 50
-1
List1=[[1,2],[3,4],[3,8]]

List2=[[1.2,2.4],[2.4,5.0],[4.5,6.0]]

List3=[]

for i,e in enumerate(List1):
   List3.append(dict(zip(List1[i],List2[i])))

print(List3)
cpt.John
  • 143
  • 1
  • 9