I have a list of Windows paths:
pathsList = ['...', '...', '...', ...]
I need to exclude the paths that contain a substring (name of a folder).
substring = "folderName"
I've tried something like this:
for item in pathsList :
if substring in item:
pathsList.remove(item)
It kinda worked for, like 2 or 3 elements of the list. It didn't search all the elements of the list. Can anyone help me understand why or find another solution? I've searched a lot and tried many solutions here on StackOverflow but nothing worked for me. I must be doing something wrong for this code to work only for a couple of items.