Skip to content

Commit 7c3728c

Browse files
committed
to create dictionary from 2 lists
1 parent 4c606cf commit 7c3728c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

book/python_tricks/one_liner_11.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Creating dictionary from 2 lists
2+
3+
## Data
4+
keys = ['a', 'b', 'c']
5+
values = [1, 2, 3]
6+
7+
## One-liner
8+
d = dict(zip(keys, values))
9+
10+
## Result
11+
print(d)

0 commit comments

Comments
 (0)