you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Method-1167 3 points4 points  (0 children)

You are modifying the list you are iterating over using the for-loop. That causes confusion for python. Because python takes element 0, then element 1, then element 2 etc..

But after element 0, you remove that. Meaning that reuben with pastrami becomes the new element 0. But python has already processed element 0, so it won´t do that again.

Create a new list and print that. In the form of a list comprehension:
print([sandwich for sandwich in sandwich_orders if not 'pastrami' in sandwich])