x = len(pdklist)
while x >= 0:
if pdklist[-1].f in errorlist:
pdklist.remove(pdklist[-1])
x -= 1
The while loop does what I want. The for loop only removes every other item in the list. It does print every item.f value though. I originally did it this way and saw it was not right but have not been able to figure out why.
for item in pdklist:
if item.f in errorlist:
print(item.f)
pdklist.remove(item)
Any help appreciated. Probably obvious once someone points it out but I don't see it.
Note: added information that the for loop prints all items but only removes half of them.