title: Membership check of items in both dict and list, in nested for-loops, without using sets?
body: <p>I have an ordered dict:  </p>
  
  <pre><code>import collections  
  collections.OrderedDict([('key', {'keyword': {'blue', 'yellow'}}), ('key1', {'keyword': {'lock', 'door'}})])
  </code></pre>
  
  <p>and list of <code>potential_matches</code>: <code>[red, blue, one]</code> </p>
  
  <p>I want to order these potential matches into one of two lists:<br>
  <code>correct = []</code> or <code>incorrect = []</code> </p>
  
  <p>If the potential match is a keyword of one of the keys in the dict, then it goes in <code>correct</code>, else it goes in <code>incorrect</code>.  </p>
  
  <p>Result of this example should be:<br>
  <code>correct = [blue]</code>, <code>incorrect = [red, one]</code>  </p>
  
  <p>Here is what I tried:  </p>
  
  <pre><code>correct = []  
  incorrect = []  
  for word in potential_matches:
      for key, value in ordered_dict.items():
          if word in value["keyword"] and word not in correct:
              correct.append(word)
          elif word not in value["keyword"] and word not in correct and word not in incorrect:
              incorrect.append(word)  
  </code></pre>
  
  <p>Essentially, all remaining words that are not a match should simply go to the other list.   </p>
  
  <p>Though it works, doesn't seem efficient. It must be a list to preserve order, and lists may overlap.   </p>
  
  <p>Note: I asked a similar question previously although in that case the situation and answer called for the use of a python set, as items were unique.  </p>