When I run the program, the for loop does not delete all the list items, but only certain ones. Why? Here is the code:
def res(array):
for i in range(len(array)):
print(array[i])
del array[i]
print(array)
arr = [10, 5, 40, 30, 20, 50]
res(arr)