Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Fredrik Lundh
Girish Sahani wrote: > Thanks!It workedi wasted a lot of time trying to find a bug in my > code...what is wrong in iterating over a list and modifying it? > Doesnt python take the modified list every time the loop starts? this is explained in the tutorial, under "the for statement": The

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Fredrik Lundh
Girish Sahani wrote: > Btw going slightly off-topic, when i try to run a code like below with > around 50 elements (pairs) in l4,python just hangs. Any ideas why this is > happening...the data is not that large :(( building a filtered new list by repeatedly removing stuff from a copy of the origi

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Paul McGuire
"Girish Sahani" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I am trying to modify a list of pairs (l4) by removing those > pairs which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Boris Borcic
Girish Sahani wrote: > Hi, > I am trying to modify a list of pairs (l4) by removing those > pairs which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not give the correct output. Please help! > Its possible

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Maric Michaud
Le Lundi 12 Juin 2006 11:06, Girish Sahani a écrit : > Thanks!It workedi wasted a lot of time trying to find a bug in my > code...what is wrong in iterating over a list and modifying it? > Doesnt python take the modified list every time the loop starts? Python iterates over an iterator, that m

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Girish Sahani
Thank you Markthis works too... Btw going slightly off-topic, when i try to run a code like below with around 50 elements (pairs) in l4,python just hangs. Any ideas why this is happening...the data is not that large :(( > > Girish Sahani wrote: >> Hi, >> I am trying to modify a list of pairs (

Re: Function to remove elements from a list not working

2006-06-12 Thread bruno at modulix
Girish Sahani wrote: > Hi, > I am trying to convert a list of pairs (l4) to list l5 by removing those > pairs from l4 which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not give the correct output. Pleas

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Girish Sahani
Thanks!It workedi wasted a lot of time trying to find a bug in my code...what is wrong in iterating over a list and modifying it? Doesnt python take the modified list every time the loop starts? Also in this case, i want to add a condition that if none of the pairs are in pairList, element = [

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread [EMAIL PROTECTED]
Girish Sahani wrote: > Hi, > I am trying to modify a list of pairs (l4) by removing those > pairs which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not give the correct output. Please help! > Its possible

Re: Function to remove elements from a list not working (corrected)

2006-06-12 Thread Maric Michaud
Le Lundi 12 Juin 2006 10:25, Girish Sahani a écrit : > Hi, > I am trying to modify a list of pairs (l4) by removing those > pairs which are not present in a third list called pairList. > The following is a simplified part of the routine i have written. However > it does not give the correct outpu

Function to remove elements from a list not working (corrected)

2006-06-12 Thread Girish Sahani
Hi, I am trying to modify a list of pairs (l4) by removing those pairs which are not present in a third list called pairList. The following is a simplified part of the routine i have written. However it does not give the correct output. Please help! Its possible i have made a trivial mistke sinc

Re: Function to remove elements from a list not working

2006-06-12 Thread Maric Michaud
Le Lundi 12 Juin 2006 10:12, Girish Sahani a écrit : > def getl5(): >     l5 = [] >     pairList = [[1,2],[3,4],[3,5],[3,6],[9,7],[8,9],[8,7],[7,9],[11,10]] >     l4 = > [[4,2],[4,7],[4,10],[4,12],[9,2],[9,7],[9,10],[9,12],[11,2],[11,7]] for > pair in l4: >         if pair not in pairList: >      

Function to remove elements from a list not working

2006-06-12 Thread Girish Sahani
Hi, I am trying to convert a list of pairs (l4) to list l5 by removing those pairs from l4 which are not present in a third list called pairList. The following is a simplified part of the routine i have written. However it does not give the correct output. Please help! Its possible i have made a