n00m <[EMAIL PROTECTED]> writes: > def f(i,sm): > if i+1==len(a): > print sm+a[i] > return sm+a[i] > else: > f(i+1,sm+a[i]) > > a=[1,2,3,4,5] > > print f(0,0) > > >>> > 15 > None > >>>
Here's one to meditate on: >>> def foo(): ... print "foo" ... >>> print foo() foo None >>> def bar(): ... return "bar" ... >>> print bar() bar >>> def baz(): ... pass ... >>> print baz() None It should be fairly clear how these three are different. If not, I suspect you haven't worked your way through the Python tutorial; please do so. <URL:http://www.python.org/tut/> -- \ "Are you pondering what I'm pondering?" "Well, I think so, | `\ Brain, but if Jimmy cracks corn, and no one cares, why does he | _o__) keep doing it?" -- _Pinky and The Brain_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list