>>> c = 0
>>> def move(x, n, y):
... global c
... print 'steps %d. move disk %d from %s to %s'%(++c, n, x, y)
...
>>> def hanoi(n, x, y, z):
... if n==1:
... move(x, 1, z)
... else:
... hanoi(n-1, x, z, y)
... move(x, n, z)
... hanoi(n-1, y, x, z)
...
>>> hanoi(5, 'x', 'y', 'z')