removing elements incrementally from a list

Posted by Javier on Stack Overflow See other posts from Stack Overflow or by Javier
Published on 2010-05-19T10:59:16Z Indexed on 2010/05/19 11:10 UTC
Read the original article Hit count: 210

Filed under:
|
|
|

Dear all,

I've a list of float numbers and I would like to delete incrementally a set of elements in a given range of indexes, sth. like:

for j in range(beginIndex, endIndex+1):
   print ("remove [%d] => val: %g" % (j, myList[j]))
   del myList[j]

However, since I'm iterating over the same list, the indexes (range) are not valid any more for the new list. Does anybody has some suggestions on how to delete the elements properly?

Best wishes

© Stack Overflow or respective owner

Related posts about python

Related posts about list