def remove_over_5(list):
i=0
for n in list:
if n > 5:
del list[i]
i += 1
return list
print(remove_over_5([1,2,3,4,5,6,7,8,9]))
This function only deletes the numbers 6 and 8. Why are 7 and 9 skipped?
def remove_over_5(list):
i=0
for n in list:
if n > 5:
del list[i]
i += 1
return list
print(remove_over_5([1,2,3,4,5,6,7,8,9]))
This function only deletes the numbers 6 and 8. Why are 7 and 9 skipped?