Problem

Python

Consider the following list,

numbers = list(range(10))
print(numbers)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Now run the following code, given the above list. Explain the weird behavior that you observe.

for n in numbers:
    i = len(numbers)//2
    del numbers[i]
    print ('n={}, del {}'.format(n,i), numbers)

Comments