Trying to make a list that puts the zeros onto the end. And it ignores the 0.0 which also need to be put on the end as a 0. Why is this happening?
Tried using float(0)/ 0.0
. It works if I change it to a different integer just not 0.0.
Desired output [9, 9, 1, 2, 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
def move_zeros(array):
count = 0
for x in array: #counts how many zeros
if x is 0 or float(0):
count+=1
array = [x for x in array if x is not 0] # removes all zeros
array = [x for x in array if x is not float(0)]
for y in range(count):
array.append(0) #tacks zero to the end of list
print(array)
move_zeros([9,0.0,0,9,1,2,0,1,0,1,0.0,3,0,1,9,0,0,0,0,9])
Expected to to work but it ignores 0.0