l.pop()
removes elements from the list, so your list is getting smaller but you are not adjusting your iteration.
>>> x = [1,2,3]
>>> x.pop(0)
1
>>> x
[2, 3]
>>> x.pop(1)
3
>>> x
[2]
>>> x.pop(2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: pop index out of range
I would suggest you take a different approach. You could iterate over the elements of the list directly and print the ones that have "a"
in them.
for i in l:
if "a" in i:
print(i)
If you need the list to have only the elements that have "a"
in them at the end of your iteration, perhaps you would like to add those items to a new list.
things_with_a_in_them = []
for i in l:
if "a" in i:
things_with_a_in_them.append(i)
print(i)
If you want it to be terser...
things_with_a_in_them = [i for i in l if "a" in i]
map(print, things_with_a_in_them)
Have fun playing around with different approaches.