Mike Nickey wrote:

> What I have is this:
> firstList = ['a', 'b', 'c']
> secondList = [1,2,3]
> thirdList = [1.20, 1.23, 2.54]
> 
> What I am looking for is something like this for output:
> {'a': [1, 1.20], 'b': [2, 1.23], 'c': [3, 2.54]}

To get this combine second and third into the list of values and then build 
the final dict using it:

>>> first = ['a', 'b', 'c']
>>> second = [1, 2, 3]
>>> third = [1.20, 1.23, 2.54]
>>> values = zip(second, third)
>>> values
[(1, 1.2), (2, 1.23), (3, 2.54)]
>>> dict(zip(first, values))
{'a': (1, 1.2), 'c': (3, 2.54), 'b': (2, 1.23)}

If tuples as values are not acceptable: 

values = map(list, values)


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to