Okay this may be really trivial (I am pretty new to this), but I have been stuck at this for a while and I do not understand why my function below is returning such a weird result.
testx = [(1,2), (1,1), (2,2), (3,5), (4,4), (5,5)]
def test_loop(interval_set):
for item in interval_set:
if item[0] == item[1]:
interval_set.remove(item)
return interval_set
print test_loop(testx)
>>>[(1, 2), (2, 2), (3, 5), (5, 5)]
If you notice, only repetitive sets (1,1) and (4,4) got removed while (2,2) and (5,5) remained in the list. This is almost illogical, please assist.