title: Towers of Hanoi Python - understanding recursion
body: <p>I'm completely new to Python and I am currently going over a tutorial about The Towers of Hanoi and recursion. I thought that I understood recursion until they gave this example:</p>
  
  <pre><code>def moveTower(height,fromPole, toPole, withPole):
      if height &gt;= 1:
          moveTower(height-1,fromPole,withPole,toPole)
          moveDisk(fromPole,toPole)
          moveTower(height-1,withPole,toPole,fromPole)
      #print(withPole)
  
  def moveDisk(fp,tp):
      print("moving disk from",fp,"to",tp)
  
  
  moveTower(3,"A","B","C")
  </code></pre>
  
  <p>which prints the correct moves for solving the towers of hanoi problem with 3 discs:
  moving disk from A to B
  moving disk from A to C
  moving disk from B to C
  moving disk from A to B
  moving disk from C to A
  moving disk from C to B
  moving disk from A to B</p>
  
  <p>My question is, how does it do so?! could someone go over the lines of code so that I understand how it prints the correct moves? I'm mainly confused with how the value of <code>fp</code> and <code>tp</code> can change from <code>A</code> to <code>B</code> to <code>C</code>. Sorry if this is bit of a broad question! Any help would be greatly appreciated!</p>