Hash from two arrays: Difference between revisions

(→‎[[Ruby]]: flatten appears to be necessary here)
Line 168:
[[Category:Python]]
'''Interpreter:''' [[Python]] 2.5
<pre>
keys = ['a', 'b', 'c']
valueskeys = [1'a', 2'b', 3'c']
values = [1, 2, 3]
hash = dict(zip(keys, values))
 
# Lazily:
from itertools import izip
hash = dict(izip(keys, values))
</pre>
 
==[[Ruby]]==
Anonymous user