How can I delete a specific repetitive number in a list?
<p>For example I have </p>

<pre><code>[3, 4, 5, 5, 12, 13, 0, 0, 0, 8, 15, 17, 0, 0, 0]
</code></pre>

<p>I want delete just all the zeros. 
Note: assume that we have an unknown number of zeros in a list that has an unknown length. </p>

<p>List comprehensions make this easy:</p>

<pre><code>new_list = [x for x in orig_list if x != 0]
</code></pre>

<p>You can push the work to the C layer with <code>filter</code>:</p>

<pre><code># If they're all numbers, you can avoid work by using filter with None:
new_list = list(filter(None, orig_list))  # List wrapper not needed on Py2

# If falsy values that aren't numeric zero might be found, and should be kept, you'd do:
new_list = list(filter((0).__ne__, orig_list))  # List wrapper not needed on Py2
</code></pre>

python list