TypeError, I know why but not how!?
Robert Kern
robert.kern at gmail.com
Wed Jul 9 22:17:02 EDT 2008
ssecorp wrote:
> Im looking into PvsNP:
> http://www.claymath.org/millennium/P_vs_NP/
> so I thought I'd write the program just to get a feel for it.
>
>
> But I run into a problem. Why does it all the sudden return None? I
> mean I know why the program aborts but I dont understand why the None
> is generated all the sudden. Hitting recursion depth isn't reported
> with that error.
def validate(placed):
student = round(random.random()*401)
if student in placed:
# You need to explicitly return, here:
return validate(placed)
else:
placed.append(student)
return student, placed
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list