Error in Chain of Function calls

Fredrik Lundh fredrik at
Fri Jun 9 13:55:23 CEST 2006

Girish Sahani wrote:

>> what error ?
> ...line 266, in colocationMiner
> prunedNew = genColocations(prunedK)
> genColocations is a function defined before which returns prunedNew.

that's a line of code, not an error.  please include the entire 
traceback, or at least the actual error message.  also see:

>>> The error is:
>>> prunedNew.remove(s)
>>> ValueError: list.remove(x): x not in list
>> the ValueError means exactly what it says -- have you verified that the
>> value of "s" really is present in the list?  did you really mean to
>> remove "s" and not, say, "string" ?
> Yes. I want to remove s from the prunedNew list if that condition is not
> satisfied.

are the item you want to remove in the list?  if you cannot be sure of 
that when you call remove, you need to check first (or catch the 
exception).  i.e.

     if s in prunedNew:


         prunedNew.remove(s) # remove, if present
     except ValueError:
         pass # ignore error if not present


More information about the Python-list mailing list