Imagine that you have:
keys = [\'name\', \'age\', \'food\'] values = [\'Monty\', 42, \'spam\']
What is the simplest way to produce the foll
Try this:
>>> import itertools >>> keys = ('name', 'age', 'food') >>> values = ('Monty', 42, 'spam') >>> adict = dict(itertools.izip(keys,values)) >>> adict {'food': 'spam', 'age': 42, 'name': 'Monty'}
In Python 2, it's also more economical in memory consumption compared to zip.
zip