def del_zeros(lst, n):
    lst = (list(j)[:n] if i else list(j) for i, j in itertools.groupby(lst,
        key=lambda x: x == 0))
return [item for sublist in lst for item in sublist]
How can I delete all zeros except for x of them in every run of consecutive zeros within a list?