Skip to content

Commit 0eff775

Browse files
authored
create dictionary from keys as a tuple and values as list of tuples
1 parent d04e446 commit 0eff775

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

dictfromtuples.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
a = [(1, 2, 3, 4), (5, 6, 7, 8), (9,10,11,12)]
2+
k = ("id","var","v3","v4")
3+
d = []
4+
for i in a:
5+
d.append({j:i[k.index(j)] for j in k})

0 commit comments

Comments
 (0)