title: Python ValueError: list.remove(x): x not in list
body: <pre><code>def switch(g, p,n):
  final = []
  for i in range(len(p)):
      d = list(range(n))
      d.remove(g[i])
      d.remove(p[i])
  
      final.append(d)
  
  return final
  
  switch([2, 3, 0], [[1, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 5, 6, 7, 8,
  9],[1, 2, 4, 5, 6, 7, 8, 9]],11)
  </code></pre>
  
  <p>But when I run this code I get the following error:</p>
  
  <pre><code>ValueError                                Traceback (most recent call last) &lt;ipython-input-151-72e1cc5c9abf&gt; in &lt;module&gt;()
       10     return final
       11 
  ---&gt; 12 switch([2, 3, 0], [[1, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 5, 6, 7, 8, 9],[1, 2, 4, 5, 6, 7, 8, 9]],11)
  
  
  
  &lt;ipython-input-151-72e1cc5c9abf&gt; in switch(g, p, n)
        4         d = list(range(n))
        5         d.remove(g[i])
  ----&gt; 6         d.remove(p[i])
        7 
        8         final.append(d)
  
  ValueError: list.remove(x): x not in list
  </code></pre>
  
  <p>What am I doing wrong here? I just want the numbers of g and p removed from the list and that I get the number that is left as output.</p>