title: Tower of Hanoi Python My own way wont work
body: <p>I tried solving this problem but it did not work. Seems like the recursion does not stop.</p>
  
  <p>What i wanted to do was to move ndisks from tower A to C 1 by 1 starting from the top.</p>
  
  <pre><code>def Move(src, dest):
       dest.append(src.pop())
  
  def Hanoi(nDisks, src, dest, temp):
      numDiskMoved = 0
  
      while numDiskMoved &lt; nDisks:                
              if len(dest) == 0:   #dest is empty, go ahead and move
                                Move(src, dest)
                                numDiskMoved += 1
  
              elif dest[-1] &gt; src[-1]:  #dest disk is bigger than src Disk. Still a valid move
                                      Move(src, dest)
                                      numDiskMoved += 1
  
              else:  #situation where dest disk is smaller than src disk
                   newNDisks = len(dest) #move all of current dest disks to temp
                   Hanoi(newNDisks, dest, temp, src)
                   Move(src, dest)
                   numDiskMoved += 1
                   Hanoi(newNDisks, temp, dest, src)
  
  a = [3, 2, 1]
  b = []
  c = []
  
  Hanoi(len(src), a, c, b)
  print(c)
  </code></pre>