Was having fun with this task on code wars where on a given list as an input my function should find all of the zeroes and put them at the end of a given list maintaining the other numbers in the same order for example: a = [1, 2, 0, 1, 0, 1] function should return a = [1, 2, 1, 1, 0, 0]
I wrote a code which in my VS code does the job but for some reason cant pass the initial tests (4/5).
The thing is on failed test where my function should return some values, IT ACTUALLY DOES, in my compiler but cant pass test??? I'm really confused. I did not want to look for solutions online...
Here is my code:
def zerotoanend(a:list):
b = []
for i in a:
if i==0:
b.append(0)
a.remove(i)
for zero in b:
a.append(zero)
return a