Как и zvone, указанный в их ответе, remove()
не удаляется в соответствии с индексом, он удаляется в соответствии со значением. Чтобы удалить по индексу, используйте .pop()
:
for i in palind:
if palind[0] == palind[-1] and len(palind) % 2 == 0:
print('removing',palind.pop(0))
print('removing',palind.pop(-1))
print(palind,'is still a palindrome')
actual_palind.append(x)
else:
print(x,'is not a palindrome')
break
Вывод:
[2, 0, 0, 3, 1, 4, 4, 1, 3, 0, 0, 2] is to check
removing 2
removing 2
[0, 0, 3, 1, 4, 4, 1, 3, 0, 0] is still a palindrome
removing 0
removing 0
[0, 3, 1, 4, 4, 1, 3, 0] is still a palindrome
removing 0
removing 0
[3, 1, 4, 4, 1, 3] is still a palindrome
removing 3
removing 3
[1, 4, 4, 1] is still a palindrome
200314413002 is a palindrome