Error in Chain of Function calls
Fredrik Lundh
fredrik at pythonware.com
Fri Jun 9 07:55:23 EDT 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:
http://pyfaq.infogami.com/tutor-i-need-help-im-getting-an-error-in-my-program-what-should-i-do
>>> 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)
or
try:
prunedNew.remove(s) # remove, if present
except ValueError:
pass # ignore error if not present
</F>
More information about the Python-list
mailing list