title: I am having trouble adding a number to a previous number and so on
body: <p>So I have a text file which contains a list of numbers which I want to create a running total of. I need the first number to add to the second number and then the third number to add to the newly created second value and so on...<br>
  Like this:<br>
  <strong>Old List</strong><br>
  0.1<br>
  0.25<br>
  0.35<br>
  0.2<br>
  0.3<br>
  <strong>New List</strong><br>
  0.35<br>
  0.7<br>
  0.9<br>
  1.2<br></p>
  
  <p>Here is what I have so far</p>
  
  <pre><code>import itertools
  from itertools import zip_longest
  
  open('newfile.txt','w').writelines([ line for line in open("Test1.txt") if "WIDTH" in line])
  open('newfile2.txt','w').writelines([ line for line in open("Test1.txt") if "DEPTH" in line])
  
  with open('compiled.txt', 'w') as res, open("newfile.txt") as f1, open("newfile2.txt") as f2:
  for line1, line2 in zip_longest(f1, f2, fillvalue=""):
      res.write("{} : {}\n".format(line1.rstrip(), line2.rstrip()))
  
  for line in open("compiled.txt"):
  line = line.strip(', \n')
  parts = line.split(":")
  category = parts[0]
  value = parts[1]
  category2 = parts[2]
  value2 = parts[3]
  total = sum([int(num) for num in value])
  print (total)
  </code></pre>
  
  <p>However it gives me this error:</p>
  
  <pre><code>total = sum([int(num) for num in value])
  ValueError: invalid literal for int() with base 10: ' '
  </code></pre>
  
  <p>What am I doing wrong here? I am new to python so any help would be greatly appreciated.</p>