append zero but not False in a list python
<p>I'm trying to move all zeros in a list to the back of the line, my only problem is there is a False bool in the list. I just found out that False == 0, so how do i move all zeros to the back of the list and keep false intact?</p>

<pre><code>def move_zeros(array):
    #your code here
    for i in array:
        if i == 0:
            array.remove(i)
            array.append(i)
    answer = array
    print answer
</code></pre>

<p><code>move_zeros(["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9])</code></p>

<p>This is what it returns when you run it.</p>

<pre><code>['a', 'b', None, 'c', 'd', 1, 1, 3, [], 1, 9, {}, 9, 0, 0, 0, 0, 0, False, 0, 0, False, 0, 0]
</code></pre>

<p>The following is an O(n) linear scan algorithm, as opposed to the O(n<em>logn) and O(n</em>n) algorithms given already.  Move non-0 items just once and add 0s in one batch.</p>

<pre><code>def move_zeros(array):
    "Mutate list by putting int 0 items at the end, in O(n) time."
    dest = 0
    zeros = 0
    for item in array:
        if not item and type(item) is int:  # int 0
            zeros += 1
        else:
            if zeros:
                array[dest] = item
            dest += 1
    array[-zeros:] = [0] * zeros

inn = ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9]
move_zeros(inn)
print(inn)
# ['a', 'b', None, 'c', 'd', 1, False, 1, 3, [], 1, 9, {}, 9,
#  0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
</code></pre>

python list