title: Can someone explain why this finds the sum of my numbers?
body: <p>Im so sorry, I know this is a total noob question but I was running code for my intro class and, through the gracious help of the internet, figured out how to make it work. My only question is <em>why</em> does this work? It only looks like it's adding against total and not the other numbers. Thanks for all the help, I know its such a silly question haha.</p>
  <pre><code>def main():
  
      #opening the numbers file
      numbers = open('numbers.txt', 'r')
  
      total = 0
      #making a for loop
      for line in numbers:
          total += int(line)
      print(&quot;The sum for all numbers in the numbers.txt file is:&quot;, total)
  
  #calling main
  if __name__ == '__main__':
  main()
  </code></pre>
  <p>edit: thank you all so much for the responses(and the new line of code for the sum function! I didn't know that. How cool!). I literally just made an acct so I'm not familiar w/ the website layout at all but I think I've got it down now. Thank you again for explaining it!! :)</p>