dictA = dict(zip(list1, list2))
More info on the zip
function is available here:
http://docs.python.org/2/library/functions.html#zip
The above line first evaluates the zip(list1, list2)
, which creates a list containing n tuples out of the nth element of the two lists. The dict
call then takes the list of tuples and creates keys out of the first value in the tuple, with the value of the respective key being the second value.