As you removing items from the list, range(len(test)) still holds the same value. So even if your test list has only no items left, the loop is still going.
I have two solutions:
Copy the items you want to a new list, so instead of deleting it:
test2 = test[i]
And don't forget to reverse the conditions.
Loop it backwards. Like this:
n = len(test)
for i in range(n):
j = n - i - 1
if j > 1:
if test[j][0:2] == test[j-1][0:2]:
test.remove(test[j])
Or, as martijn suggested:
n = len(test)
for i in range(n-1, 0, -1):
if i > 1:
if test[i][0:2] == test[i-1][0:2]:
test.remove(test[i])
Hope it helps!
P.S sorry for my stupid, previous answer