where the function has problem? n = 900 is OK , but n = 1000 is ERROR
Thomas Rachel
nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Mon Aug 1 10:25:43 EDT 2011
Am 01.08.2011 11:11 schrieb jc:
> except:
> print "EXCEPT: " + str(n)
If you catch all exceptions here, it is clear that you only get this.
Why don't you do
except Exception, e:
print "EXCEPT: " + str(n), e
? Then you could at least ask "why do I get a unsupported operand
type(s) for +: 'NoneType' and 'long'"?
Well, these are the consequences of returning nothing (aka None) in the
case of earlier errors. The first of these errors comes from
EXCEPT: 4 maximum recursion depth exceeded
so - you simply go too deep.
If you "pre-calculate" the stuff before, calling fibo(n/2) before the
line with 'print "Fibo(" + str(n) + ") = " + str(fibo(n))', it succeeds.
Thomas
More information about the Python-list
mailing list