Untitled
#тестовые данные 11 0 0 12 выход - 0 12 или тестовые данные - 1 2 0 3 4 0 5 10 выход - 1 0 3 0 5 10 a = list(map(int, input().split())) indexes = len(a) nulles = a.count(0) must_be = indexes - nulles def foo(a): for i in range(len(a)): if a[i] == 0 and i != 0 and len(a) != must_be: index_delete = i-1 a.pop(index_delete) foo(a) elif len(a) != must_be: continue else: break # indexes = len(a) # while indexes != must_be: # foo(a) foo(a) print(*a)
Leave a Comment