title: Sum float numbers from a list
body: <p>I have a list of numbers which were taken from a file.</p>
  <pre><code>fh = open(&lt;filename&gt;)
  for line in fh:
      if not line.startswith(&quot;X-DSPAM-Confidence:&quot;) : continue
      num = float(line[20 : ])
      print(num)
  </code></pre>
  <p>Output:</p>
  <pre><code>0.6178
  0.6961000000000001
  0.7565
  0.7625999999999999
  0.7556
  0.7002
  0.7615
  </code></pre>
  <p>I have to sum all of them and take the average (&quot;I can't use sum()&quot;). I tried looping through all of them with 'for', to then sum and get the average with / operator; but I get the following error 'float' object is not iterable.</p>
  <p>What I tried:</p>
  <pre><code>fh = open(&lt;filename&gt;)
  for line in fh:
      if not line.startswith(&quot;X-DSPAM-Confidence:&quot;) : continue
      num = float(line[20 : ])
      for n in num: 
          n = n + n  
      print(n)
  </code></pre>
  <p>With this a get the error of 'float' object is not iterable.</p>
  <p>Also I tried adding the numbers to an array too see if can loop in an array but that didn't work for me either.</p>