title: List Index Out of Range in Python; Iteration
body: <p>I am using the simple program below to see how long an iterative process takes to terminate. However, in line 15, I cannot figure out why I am getting index out range error.</p>
  
  <p>An example of what I am trying to count is the number of steps it takes for the following example iteration: User inputs 4 and then 1234. Then we have: [1,2,3,4] --> [1,1,1,1] --> [0,0,0,0] and then termination. 2 steps is required to get to [0,0,0,0]. I have proven that for the values of n that I am inserting, the system goes to [0,0,0,0] eventually. </p>
  
  <pre><code>import math
  index = input("Enter length: ")
  n = int(index)
  game = input("Enter Coordinates of length n as a number: ")
  s = list(game)
  Game = []
  for k in s:
      Game.append(int(k))
      l = len(game)
  while sum(Game) &gt; 0:
      Iteration = []
      k = 0
      j = 0
      while j &lt; l-1:
          Iteration.append(math.fabs(Game[j]-Game[j+1])) # line 15
          j = j+1
          k = k+1
          Game = Iteration
  print(k)
  </code></pre>