This error is because you are reducing the length of your list l as you iterate over it, so as you approach the end of your indices in the range statement, some of those indices are no longer valid.
I think you want to do is:
l = [x for x in l if x != 0]
This will return a copy of l without any of the elements that were zero. You could even shorten that last part to just if x, since non-zero numbers evaluate to True.
You can write the fresh code as follows:
i = 0
while i < len(l):
if l[i] == 0:
i += 1
To know more about this you can have a look at the following video tutorial:-