title: How to access a list in a nested defaultdict python 2.7?
body: <p>I have the code below, which is able to give me the documents frequency for each <code>wordQ1</code>, now I need the term frequency <code>TF</code> of <code>wordQ1</code> (<code>TF</code> in each document <code>DocID</code>) and the <code>DocSize</code> of each <code>DocID</code>.</p>
  
  <p>The data structure is like that:</p>
  
  <pre><code>FinalHash[wordQ1]={DocID: [TF,DocSize]}
  </code></pre>
  
  <p>My output should be like the following:</p>
  
  <ul>
  <li>The current document is 999</li>
  <li>The number of tokens contains in this document is 59 </li>
  <li>george document frequency is 142 (I have this done)</li>
  <li><p>george term frequency in file 999 is 5</p>
  
  <pre><code>Term_List1=[]
  DF1 = 0
  Term_List1 = FinalHash[wordQ1] # FinalHash is defaultdict
  for d in Term_List1: # is the list of all dictionaries where each dict contains {DocID: [TF,DocSize]}
      for i in d.keys(): # in this case i is the docID
          DF1 = DF1+1 # counter to get the document frequency of a term
          print i
  
  print "document frequency of wordQ1 is",DF1 # document frequency 
  </code></pre>
  
  <p>Thanks a lot for your help</p></li>
  </ul>