how to delete multiple elements from a list

Mikael Olofsson mikael at
Tue Nov 21 08:36:49 CET 2000

On 14-Nov-00 etsang at wrote:
 >  I have a List X with N number of items in it. I have another List Y
 >  which contains the postion of the elements to be deleted from List X.
 >  I cannot do a for loop to delete that because for each iteration, List
 >  X will be changed and there will be sliperage.

You _can_ do that with a loop. Just make sure that you have Y in reverse

for y in Y:
  del X[y]

 >  How can I delete all the items as specified by the positions in Y at
 >  one time? 

I will leave that one to someone else.



E-Mail:  Mikael Olofsson <mikael at>
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date:    21-Nov-00
Time:    08:29:07

         \ /     ASCII Ribbon Campaign
          X      Against HTML Mail
         / \

This message was sent by XF-Mail.

More information about the Python-list mailing list