I think the problem is in the following:
>>>list(range(0,30,2))
will release a list with the following items:
>>>[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]
that is what is stored in your list. They are only 15 numbers all pairs. The for i in range (0,30)
takes into account elements that are not even: (0,1,2,3 ... 29). Then your mistake is that you ask him to remove the index when it is not even.
I give you a clarifying example: in the first iteration the index is 0; when you reach the point of numbers.remove(i)
; i will value 0. For being the index; coincidentally, it is also the first item on your list. However in the second iteration; i takes the value 1; numbers [1] has assigned the value two, which according to your code enters the block:
if numbers[i] % 2 == 0:
numbers.remove(i)
but .. how are you going to remove value 1? That number is not on the list.
I hope this explanation has been useful. Greetings.