I am struggling to find any documentation anywhere on what this actually is. I understand just an ordinary dictionary. This consists of key and value pairs so if you search for a key its corresponding value is returned, For example:
myDict = {‘dog’ : ’fido’, ‘cat’ : ’tiddles’, ‘fish’ : ’bubbles’, ’rabbit’ : ’thumper’}
And then you can invoke certain methods on this like:
myDict[‘fish’]
returns
'bubbles'
or
myDict.has_key(‘tiddles’)
returns
True
How would a two-level dictionary compare to this?
It appears nested dictionaries was what I was looking for.
One more question, say I have a nested dictionary which links words to text files where the first integer is the number of the text file and the second is the number of occurrences:
myDict = {'through':{1:18,2:27,3:2,4:15,5:63}, 'one':{1:27,2:15,3:24,4:9,5:32}, 'clock':{1:2,2:5,3:9,4:6,5:15}
How would I use the file numbers to work out the total number of text files that were present? i.e is there a way of extracting the number of key / value pairs in the inner dictionary?