zip to a dictionary : zip « Buildin Function « Python Tutorial






keys = ['A', 'B', 'C']
vals = [1, 3, 5]


print zip(keys, vals)

D2 = {}
for (k, v) in zip(keys, vals): D2[k] = v
print D2








13.49.zip
13.49.1.zip() zips together the sequences, returning a list of tuples:
13.49.2.Use zip function in for loop
13.49.3.zip() stops when the shortest sequence is "used up" for different lengths
13.49.4.enumerate() and zip()
13.49.5.zip to a dictionary