removing a number from a list
<p>I'm stuck on a part of a looping question. I have to remove from list1 all instances of "number". So lets say list1 is (1,2,3) and num is 2. The list I would have to return would be (1,3)</p>

<pre><code>def remove(list1,num)

    list1=list1
    num = num
</code></pre>

<p>This is what is given. 
So far, I have this:</p>

<pre><code>def remove(list1,num)

list1=list1

num=num

if num in list1:
</code></pre>

<p>This is where I'm stuck because I don't know how to say in coding "remove num from list" 
I am not allowed to use .remove either. </p>

<p>Would appreciate the help.</p>

<p>Taking into account:</p>

<pre><code>list=[1,2,3,2]
</code></pre>

<p>You can check if the element is in the list with:</p>

<pre><code>if num in list
</code></pre>

<p>And then remove with:</p>

<pre><code>list.remove(num)
</code></pre>

<p>And iterate through it</p>

<p>Example:</p>

<pre><code>&gt;&gt;&gt; list=[1,2,3]
&gt;&gt;&gt; list.remove(2)
&gt;&gt;&gt; print list
[1, 3]
</code></pre>

python loops for-loop