to the interpreter to get feel for some of the dictionary operations in table - basic dictionary operations in normal operationyou create dictionaries with literals and store and access items by key with indexingpython {'spam' 'ham' 'eggs' ['spam' {'eggs' 'spam' 'ham' make dictionary fetch value by key order is "scrambledherethe dictionary is assigned to the variable dthe value of the key 'spamis the integer and so on we use the same square bracket syntax to index dictionaries by key as we did to index lists by offsetbut here it means access by keynot by position notice the end of this example--much like setsthe left-to-right order of keys in dictionary will almost always be different from what you originally typed this is on purposeto implement fast key lookup ( hashing)keys need to be reordered in memory that' why operations that assume fixed left-to-right order ( slicingconcatenationdo not apply to dictionariesyou can fetch values only by keynot by position technicallythe ordering is pseudo-random--it' not truly random (you might be able to decipher it given python' source code and lot of time to kill)but it' arbitraryand might vary per release and platformand even per interactive session in python the built-in len function works on dictionariestooit returns the number of items stored in the dictionary orequivalentlythe length of its keys list the dictionary in membership operator allows you to test for key existenceand the keys method returns all the keys in the dictionary the latter of these can be useful for processing dictionaries sequentiallybut you shouldn' depend on the order of the keys list because the keys result can be used as normal listhoweverit can always be sorted if order matters (more on sorting and dictionaries later)len( 'hamin true list( keys()['eggs''spam''ham'number of entries in dictionary key membership test alternative create new list of ' keys observe the second expression in this listing as mentioned earlierthe in membership test used for strings and lists also works on dictionaries--it checks whether key is stored in the dictionary technicallythis works because dictionaries define iterators that step through their keys lists automatically other types provide iterators that reflect dictionaries in action