hi, i have the following recursive function (simplified to demonstrate
the problem):
[color=blue][color=green][color=darkred]
>>> def reTest(bool):[/color][/color][/color]
.... result = []
.... if not bool:
.... reTest(True)
.... else:
.... print "YAHHH"
.... result = ["should be the only thing returned"]
.... print "printing result: "
.... print result
.... return result
....[color=blue][color=green][color=darkred]
>>> reTest(False)[/color][/color][/color]
YAHHH
printing result:
['should be the only thing returned']
printing result:
[]
[]
I don't understand why results are returned twice? is there something
special i missed about recursive functions?
the problem):
[color=blue][color=green][color=darkred]
>>> def reTest(bool):[/color][/color][/color]
.... result = []
.... if not bool:
.... reTest(True)
.... else:
.... print "YAHHH"
.... result = ["should be the only thing returned"]
.... print "printing result: "
.... print result
.... return result
....[color=blue][color=green][color=darkred]
>>> reTest(False)[/color][/color][/color]
YAHHH
printing result:
['should be the only thing returned']
printing result:
[]
[]
I don't understand why results are returned twice? is there something
special i missed about recursive functions?
Comment