Python runtime error
why isn't mcnt a global variable??? ......................................... Below is the recursive algorithm to preform the towers of hanoi. For n rings move n-1 rings to the temperary peg, then move the nth ring form source peg to the final peg. Now move n-1 rings from the temperary peg to the to the final peg ''' #global mcnt mcnt = 0 def hanoi(n, a, b, c): #mcnt += 1 if n <= 0: return hanoi(n-1, a, c, b) report(n, a, b) hanoi(n-1, c, b, a) def report(n, a, b): pna=['a', 'b', 'c'] x, y = pna[a], pna[b] #mcnt = 1 mcnt += 1 printf("Move# %d ring %d from peg %c to peg %c\n", mcnt,n, x, y ); …………………………………………………………. File "./Playground/file0.py", line 40, in report mcnt += 1 UnboundLocalError: local variable 'mcnt' referenced before assignment ……………………………………………………………… in report mcnt += 1 UnboundLocalError: local variable 'mcnt'