title: Why is my list getting shorter and shorter?
body: <p>I am trying to do Project Euler problem 8. Here is the general idea behind what I am doing:</p>
  
  <ul>
  <li>I am saving the numbers they gave in a text file;</li>
  <li>I am reading the numbers from the file into a list;</li>
  <li>I am checking the product of every 13 number chunk while in the row; and </li>
  <li>for now I am outputting what set of 13 numbers is making up the chunk (I did this because my output kept coming out wrong, so I am making sure that my program is correctly reading each chunk.)</li>
  </ul>
  
  <p>I had several issues come up with my program and in my troubleshooting process I've found that, for some reason, my list that stores the current row is getting shortened until it is non-existent. I'm not sure why this is happening, what can I do to fix this?</p>
  
  <p>Here is my source code:</p>
  
  <pre><code>with open("product.txt") as f:
      array = []
      for line in f:
          line = line.split()
          if line:
              line = [int(i) for i in line]
              array.append(line)
  
  def product(k): #Largest product of row k
      i = 0 #The start of the chunk of 13 terms
      row = str(array[k][0])
      while i &lt; len(row) - 12: #Stop when i is 13 characters away from end of row
          j=0 #The start of our run-through of the chunk
          total = 1 #Set this value to 1 so that we can compare the next chunk of 13
          while j &lt; 13: #Go outward to the 12th element only since we include 0
              total = total * int(row[i+j]) #The first character * the next 12
              j += 1
             #End of j while
  
          print (row[i:13]) #To verify that the program is reading size 13 blocks
          i += 1 #End of i while
  
      return total
  
  print (product(0))
  </code></pre>
  
  <p>The text file is just a copy and paste of the numbers from <a href="https://projecteuler.net/problem=8" rel="nofollow">problem 8</a>.</p>