3 ms·
It is actually much simpler: you change 'n' as well: while i < n: if shouldDelete(iterable[i]): del iterable[i]; n -= 1 else: i
by Mikhail_Edoshin 3y ago
It is actually much simpler: you change 'n' as well:
while i < n:
if shouldDelete(iterable[i]):
del iterable[i]; n -= 1
else:
i += 1