title: Python : Finding all the prime numbers in a list. What am I doing wrong?
body: <p>I am trying to find all the prime numbers in a given list. I am not sure why this code is not working. I tried doing it with flags as well. Thanks for your help.  </p>
  
  <pre><code>def prime_factor(n):  
  for i in n:
      for j in range(2,i):
          if i%j == 0:
              n.remove(i)
              break
  return n  
  prime_factor([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])
  </code></pre>
  
  <p>Output : [1, 2, 3, 5, 7, 9, 11, 13, 15, 17, 19]</p>