it' common to occasionally end up with two sequences that you want to pair up element-wise in dict as first cutyou might write code like thismapping {for keyvalue in zip(key_listvalue_list)mapping[keyvalue since dict is essentially collection of -tuplesit should be no shock that the dict type function accepts list of -tuplesin [ ]mapping dict(zip(range( )reversed(range( )))in [ ]mapping out[ ]{ in later section we'll talk about dict comprehensionsanother elegant way to construct dicts default values it' very common to have logic likeif key in some_dictvalue some_dict[keyelsevalue default_value thusthe dict methods get and pop can take default value to be returnedso that the above if-else block can be written simply asvalue some_dict get(keydefault_valueget by default will return none if the key is not presentwhile pop will raise an exception with setting valuesa common case is for the values in dict to be other collectionslike lists for exampleyou could imagine categorizing list of words by their first letters as dict of listsin [ ]words ['apple''bat''bar''atom''book'in [ ]by_letter {in [ ]for word in wordsletter word[ if letter not in by_letterby_letter[letter[wordelseby_letter[letterappend(wordin [ ]by_letter out[ ]{' '['apple''atom']' '['bat''bar''book']the setdefault dict method is for precisely this purpose the if-else block above can be rewritten asdata structures and sequences www it-ebooks info