title: How do I compare two lists in python
body: <p>I have two lists. The first list contains only strings (basically, it contains foreign words) and the second list contains only strings (it's composed of the words the user already knows). I want to compare the two lists and remove from list 1 the words of list 2.
  How can I do that?</p>
  <p>My attempt:</p>
  <pre><code>   all_words = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
          
     def compare_lists (all_words):
         known_words = ['A', 'B', 'C', 'D', 'E',]
         for i in all_words:
             if i in known_words:
                 all_words.remove(i)
         return all_words
     
     unknown_words = compare_lists(all_words)
     
     print(unknown_words)
  </code></pre>
  <p><strong>Expected output: F, G, H, I.</strong></p>
  <p>A long story short, the code doesn't work. I can't quite pinpoint what it does but it seems to remove only one word from the &quot;all_words&quot; list (probably, the code doesn't even work at all but that's just my impression).</p>
  <p>Thank you in advance.</p>