
John L. answered 05/24/19
Tutor
4.9
(221)
Machine Learning Professor and More
Yes, Python has dictionary comprehensions. You almost have the syntax correct. If you have two sequences, one of keys, and one of values, this will work:
myDict = {k:v for (k,v) in zip(keys, values)}

John L.
Oh, and I almost forgot, there's a shortcut for the above: "myDict = dict(zip(keys, values))" does exactly the same thing, even though it doesn't look like the list comprehension syntax.05/24/19