title: Having difficulties to delete class instances from a list in python
body: <p>I have seen a similar question <a href="https://stackoverflow.com/questions/9140857/oop-python-removing-class-instance-from-a-list">OOP python - removing class instance from a list</a>, but the solution is not working for me.</p>
  
  <p>I made a full class test. And the result is not passing the test.</p>
  
  <p>I'm using python 3.4.4</p>
  
  <pre><code>import random
  </code></pre>
  
  <p>A simple class</p>
  
  <pre><code>class J():
      def __init__(self):
          self.jota = 0
  
      def up_j(self):
          self.jota = random.choice([2, 0])
  
      def get_j(self):
          return self.jota
  
      def __str__(self):
          return str(self.jota)
  </code></pre>
  
  <p>A list in which I can append instances of the class</p>
  
  <pre><code>a = []
  </code></pre>
  
  <p>Appending class instances</p>
  
  <pre><code>for i in range(20):
      a.append(J())
  </code></pre>
  
  <p>Changing it up a bit</p>
  
  <pre><code>for e in a:
      e.up_j()
  </code></pre>
  
  <h2>Here is the FUNCTION I want to get right</h2>
  
  <pre><code>def x(a):
      for i, o in enumerate(a):
          if o.get_j() == 0:
             del a[i]
      return a
  </code></pre>
  
  <p>Applying the function</p>
  
  <pre><code>a = x(a)
  </code></pre>
  
  <p>Testing! Notice that all numbers in the result should be zero.
  But that is not the case</p>
  
  <pre><code>for each in a:
      print(each)
  </code></pre>
  
  <p>Results!</p>
  
  <pre><code>2
  2
  0
  0
  ...
  </code></pre>