I want to delete all the elemnts of the list from the index 4 to 9. Why isn't the code below working.
m=[0,1,2,3,4,5,6,7,8,9]
for i in range(4,10,1):
del m[i]
The output is:
Traceback (most recent call last):
File "<pyshell#45>", line 2, in <module>
del m[i]
IndexError: list assignment index out of range
But after this the contents of m becomes `[0, 1, 2, 3, 5, 7, 9]