keys = ['a', 'b', 'c']
values = [10, 20, 30]
dic = dict(zip(keys, values)) # => {'a': 10, 'b': 20, 'c': 30}
dict (iter)
(ʻiteris an iterable object) is a dictionary with ʻiter [i] [0]
as the key and ʻiter [i] [1] as the value for each element of ʻiter
. Returns (equivalent to the code below). If len (iter [i])! = 2
, then ValueError occurs.
dic = {}
for k, v in iter:
dic[k] = v