human
Move all zeroes to end of array | Function which pushes all zeros to end of an array ..
Count of non - zero elements.
Traverse the array . If element encountered is non - zero , then replace the element at index ' count ' with this element.
here count is incremented.
Now all non - zero elements have been shifted to front and ' count ' is set as index of first 0. Make all elements 0 from count to end ..
Driver code"
How can the above be solved in Python?
 Write me a code to move all zeroes to end of array and the other steps required?
assistant
#Here is code to move all zeroes to end of array and the other steps required.
 def pushZerosToEnd ( arr , n ) :
	count = 0
	for i in range ( n ) :
		if arr [ i ] != 0 :
			arr [ count ] = arr [ i ]
			count += 1
	while count < n :
		arr [ count ] = 0
		count += 1
arr = [ 1 , 9 , 8 , 4 , 0 , 0 , 2 , 7 , 0 , 6 , 0 , 9 ]
n = len ( arr )
pushZerosToEnd ( arr , n )
print ( " Array ▁ after ▁ pushing ▁ all ▁ zeros ▁ to ▁ end ▁ of ▁ array : " )
print ( arr )