samedi 3 juin 2017

For statement not removing text [duplicate]

This question already has an answer here:

I have a list called title:

title = ['Unknown: iTrader', 'Unknown: Thread Prefixes', 'Unknown: For Sale Section Rules', 'Unknown: Buy at your own risk',

And I have a for loop that looks like this:

for item in title:
    if "iTrader" in item:
        title.remove(item)
    if "Thread Prefixes" in item:
        title.remove(item)
    if "For Sale Section Rules" in item:
        title.remove(item)
    if "Buy at your own risk" in item:
        title.remove(item)

but when I print(title) it only removes the "iTrader" and the "For Sale Section Rules". Why is it not removing "Buy at your own risk" and "Thread Prefixes".

Aucun commentaire:

Enregistrer un commentaire