M
Michael T. Babcock
I have a list of column headings and an array of values:
headings, values = ['a', 'b', 'c'], [1, 2, 3]
I want to construct a dictionary such that d['a'] = 1 and so on.
The first way I tried to do this was:
d = {}
for h,v in headings, values:
d[h] = v
It turns out this doesn't work, but it was worth a try. I ended up
falling back on the more C-like:
for i in range(len(headings)):
d[h] = v
Is there anything somewhat cleaner or more pythonesque I could do
instead? Thanks.
headings, values = ['a', 'b', 'c'], [1, 2, 3]
I want to construct a dictionary such that d['a'] = 1 and so on.
The first way I tried to do this was:
d = {}
for h,v in headings, values:
d[h] = v
It turns out this doesn't work, but it was worth a try. I ended up
falling back on the more C-like:
for i in range(len(headings)):
d[h] = v
Is there anything somewhat cleaner or more pythonesque I could do
instead? Thanks.