title: Some values are not added to my dictionary from a loop
body: <p>I have this code</p>
  
  <pre><code>def query(q, L):
      result = []
      mDict = {}
      key = 0
      for x, i in enumerate(L):
          for y in i:
              if q == y:
                  key += 1
  
          if q in i:
              result.append(x)
              mDict[key]=x
  
          key = 0
  
      print (mDict)
      print (result)
  q = "h"
  l = ["phone", "power", "high", "phones"]
  query(q, l)
  </code></pre>
  
  <p>I am expecting my printed output to be </p>
  
  <p><code>{1: 0, 2: 2, 1: 3}</code></p>
  
  <p><code>[0, 2, 3]</code></p>
  
  <p>but instead I am getting</p>
  
  <p><code>{1: 3, 2: 2}</code></p>
  
  <p><code>[0, 2, 3]</code></p>
  
  <p>can anyone help me out?</p>