dictionaries another useful data type built into python is the dictionary (see typesmappingdictionaries are sometimes found in other languages as "associative memoriesor "associative arraysunlike sequenceswhich are indexed by range of numbersdictionaries are indexed by keyswhich can be any immutable typestrings and numbers can always be keys tuples can be used as keys if they contain only stringsnumbersor tuplesif tuple contains any mutable object either directly or indirectlyit cannot be used as key you can' use lists as keyssince lists can be modified in place using index assignmentsslice assignmentsor methods like append(and extend(it is best to think of dictionary as set of keyvalue pairswith the requirement that the keys are unique (within one dictionarya pair of braces creates an empty dictionary{placing comma-separated list of key:value pairs within the braces adds initial key:value pairs to the dictionarythis is also the way dictionaries are written on output the main operations on dictionary are storing value with some key and extracting the value given the key it is also possible to delete key:value pair with del if you store using key that is already in usethe old value associated with that key is forgotten it is an error to extract value using non-existent key performing list(don dictionary returns list of all the keys used in the dictionaryin insertion order (if you want it sortedjust use sorted(dinsteadto check whether single key is in the dictionaryuse the in keyword here is small example using dictionarytel {'jack' 'sape' tel['guido' tel {'jack' 'sape' 'guido' tel['jack' del tel['sape'tel['irv' tel {'jack' 'guido' 'irv' list(tel['jack''guido''irv'sorted(tel['guido''irv''jack''guidoin tel true 'jacknot in tel false the dict(constructor builds dictionaries directly from sequences of key-value pairsdict([('sape' )('guido' )('jack' )]{'sape' 'guido' 'jack' in additiondict comprehensions can be used to create dictionaries from arbitrary key and value expressions{xx** for in ( ){ when the keys are simple stringsit is sometimes easier to specify pairs using keyword argumentsdict(sape= guido= jack= {'sape' 'guido' 'jack' data structures