title: Concise a for loop (x for x in ...) in python
body: <p>I am trying to concise the following simple loop</p>
  <pre><code>a = [1,2,3,2,1,5,6,5,5,5]
  for x in set(a):
      a.remove(x)
  </code></pre>
  <p>This is working well but I need to know if it is possible to apply the concise for loop like that</p>
  <pre><code>a = [x for x in set(a):a.remove(x)]
  </code></pre>
  <p>My desire output is to get or list the duplicates only and get list of them, so the desired output is <code>[1,2,5]</code></p>
  <p>The code is working well</p>
  <pre><code>a = [1,2,3,2,1,5,6,5,5,5]
  
  for x in set(a):
      a.remove(x)
  
  print(list(set(a)))
  </code></pre>
  <p>My target is not the code but to concise the loop in the loop. I need to learn this trick.</p>
  <p>** Found a simple and effective solution:</p>
  <pre><code>print(list(set([x for x in a if a.count(x) &gt; 1])))
  </code></pre>