Hello list
I am having trouble with a variable to act as a counter in a nested recursive function which will only occasionally find an answer. Something like a static variable in C.
Why does this sort of thing not work?
def foo (n):
counter = 0
def choose (i):
if (solution found):
counter += 1
print counter, (solution)
else choose (i+1)
choose (1)I get an error message that counter is referenced before being declared.
Declaring counter as global does not help either
Incidentally how does one nest comments in python. I want to comment out part of a line. Is it just Kate my editor which won't allow it
Thanks Logesh
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
