title: Understand Python for Towers of Hanoi
body: <p>I understand the thinking of how to solve Hanoi with Python recursion, but I don’t understand how we could write this Python language:</p>
  
  <pre><code>def hanoi(n,x,y,z):
      if n == 1:
          print(x, ' --&gt; ',z)
      else:
          hanoi(n-1,x,z,y)
          print(x, ' --&gt; ',z)
          hanoi(n-1,y,x,z)
  hanoi(2,'SRC','TMP','TAG')
  </code></pre>
  
  <p>if the first step is to put (x-1) dishes from source to tmp, why we write hanoi(n-1,z,y) ? why we switch z and y?</p>
  
  <p>thanks!</p>