Python: Convert List to Dictionary

By Xah Lee. Date: . Last updated: .

Merge Two Lists into Dictionary

zip(args)

# convert 2 lists into a dictionary, use zip()

aa = [1, 2, 3]
bb = ["a", "b", "c"]

print(dict(zip(aa, bb)))
# {1: 'a', 2: 'b', 3: 'c'}

Python, Data Structure