Dictionary Built-in Functions

Here are the built-in functions that deal with dictionaries.

len ( object ) → integer

Return the number of items of a sequence or mapping.

dict ( valList ) → dictionary

Each element of the list must be a 2-element tuple; create a dict with the first element as the key and the second element as the value. Note that the zip function produces a list of 2-tuples from two parallel lists.

>>> 
dict( [('first',0), ('second',1), ('third',2)] )

{'second': 1, 'third': 2, 'first': 0}
>>> 
dict( zip(['fourth','fifth','sixth'],[3,4,5]) )

{'sixth': 5, 'fifth': 4, 'fourth': 3}