title: Updating list with a for loop
body: <p>I want to update a list like this,</p>
  
  <pre><code>_list=[i for i in range(1, 6)]
  
  for i in _list:
       _list = [j for j in _list if j**2 &lt; 25]
       print(len(_list), i)
  </code></pre>
  
  <p>but the loop runs 5 times even though the length of the list is displayed to be 4 with every execution of the loop. Is the list variable in the for statement different from that inside the loop and if so, how do I update it?</p>
  
  <p>Edit: My question seems to have been unclear to those who have answered so far, and, perhaps, to my negative marker. My code runs more along the lines of,</p>
  
  <pre><code>_list = [i for i in range(3, 5000, 2)]
  _list.append(2)
  
  for i in _list:
      _list = [x for x in _list if x%i != 0 or x==i]
      print(len(_list), i)
  </code></pre>
  
  <p>so I don't think I can use an if statement or a filter function, as far as I know. It's just a sieve and I want it to run just that way. I want the number of executions of the loop to be only as many as required and not more.</p>