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}]
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}]
Try this:
List3 = [dict(zip(*lsts)) for lsts in zip(List1, List2)]
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)