title: Adding numbers within a text file (python)
body: <p>Hi i have been given a task to read these numbers from within a text file "1,3,5,7,9,11,13,15," and to add them together how would i do this? So far i have:</p>
  
  <pre><code>file = open("C:\\Users\\Dylan\\Python\\OddNumbersAns.txt", "r")
  line = file.read()
  intline = int(line)
  print(intline)
  </code></pre>
  
  <p>But i recieve this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Users\Dylan\Python\text file add.py", line 3, in &lt;module&gt;
      intline = int(line)
  ValueError: invalid literal for int() with base 10: '1, 3, 5, 7, 9, 11, 13, 15, '
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Answer:</p>
  
  <pre><code>file = open("C:\\Users\\Dylan\\Python\\OddNumbersAns.txt", "r")
  
  line = file.read()
  
  line.split(",")
  
  print (line.split(","))
  
  total = sum([int(num) for num in line.split(',')])
  
  print(total)
  </code></pre>