0
Can Someone help me solve this?
A list of integers is given. It is required to "shrink" it by moving all non-zero elements to the left side of the list without changing their order, and all zeros to the right side. The order of the non-zero elements cannot be changed, an additional list cannot be used, and the task must be completed in one pass through the list. Print the resulting list. Example input data: 4 0 5 0 3 0 0 5 Example result: 4 5 3 5 0 0 0 0 Important. The isalpha operator may not work on the platform. If you use it in your solution, write it in the code comments :) numbers = list( range( max_number ) ) print( numbers ) if ( 0 in numbers ): numbers.remove( 0 ) print # this is what i have so far
1 Respuesta
+ 2
Hope this helps..
L= list(map(int, input().split()))
count=0
for i in L:
if i!=0:
print(i, end=" ")
count+=1
else:
continue
for i in range(len(L)-count):
print(0, end=" ")