title: Locating specific keys and corresponding values in dictionary
body: <p>I wrote the following piece of code:</p>
  
  <pre><code>def all_di(fl):
      dmm = {}
      for k in range(2):
          for i in fl:
              for m in range (len(i)-1):
                  temp = i[m:m+k+1]
                  if temp in dmm:
                      dmm[temp] += 1.0
                  else:
                      dmm[temp] = 1.0
  ##  return dmm
      p = raw_input("Enter a 2 AA long seq:")
      sum = 0
      for x,y in dmm.iteritems():
          if x == p:
              n1 = y
      for l,m in dmm.iteritems():
          if l[0] == p[0]:
              sum = sum + m
      print float(n1)/float(sum)
  
  all_di(inh) 
  </code></pre>
  
  <p>if inh  = <code>{'VE':16,'GF':19,'VF':23,'GG' :2}</code></p>
  
  <p>The code works as follows:</p>
  
  <pre><code>Enter a 2 AA long seq: VE
  </code></pre>
  
  <p>result will be = <code>16/(16+23)</code> = <code>0.41</code></p>
  
  <p>How it works: the function searches the dictionary <code>dmm</code> for the key similar to the one entered in <code>input</code> (example taken here 'VE'). It stores its value and then searches for all the key-value pairs that have the 1st letter in common and adds all its values and returns a fraction.</p>
  
  <pre><code>VE = 16
  **V**E + **V**F = 39
  = 16/39 = 0.41
  </code></pre>
  
  <p>What I want: keeping the function intact, I want to have a secondary dictionary that iterates for every key-value pair in the dictionary and stores the fractional values of it in a different dictionary such that:</p>
  
  <pre><code>new_dict = {'VE' : 0.41, 'GF':0.90,'VF':0.51, 'GG': 0.09}
  </code></pre>
  
  <p>I don't want to remove the <code>print</code> statement as it is the output for my program. I however need the <code>new_dict</code> for further work.</p>