for i in iterable:
    if i == 0:
        zeros += 1
if zeros <= max_zeros:
    yield i
else:
    zeros = 0
How can I delete all zeros except for x of them in every run of consecutive zeros within a list?