78. Python Program to Separate Zeros from the given Array elements.
How does this program work?
- This program is used to find the zeros from the given array elements using Python.
Here is the code
a = list()
number = int(input( "Enter the number of elements you want: "))
if (number % 2 == 0):
print ('Enter numbers in array: ')
for i in range(int(number)):
n = input("number : ")
a.append(int(n))
def zero(arr, number):
count = 0
for i in range(int(number)):
if a[i] != 0:
a[count] = a[i]
count+=1
while count < number:
a[count] = 0
count += 1
return(a)
zero(a, number)
print( "Array after pushing all zeros to end of array: ")
print(a)