As stummjr pointed out dictionary comprehension is useful to understand and use, especially since everything in python is a dicitonary.
Another way you could consider solving this problem is by lambda function.
makeDict = lambda keys, values: { k:v for k, v in zip(keys, values) }
makeDict( [1,2,3], list('abc') )
['a': 1, 'c': 3, 'b': 2]
Here is what makeDict looks rewritten as a regular function if this adds any clarity.
def makeDict(keys, values):
return { k:v for k, v in zip(keys, values) }
Anyway, lambdas can be something fun to play around with, also this isn't the most robust example. There is a potential for loss of data using zip. Both sequences must be the same length for it to properly work. Python will iterate through till it has pairs to match up form both sequences. The following example the extra element in values shouldn't show up in the dictionary.
{ k:v for k, v in zip( list('abc'), [1,2,3,4]) }
['a': 1, 'c': 3, 'b': 2]