title: How to summarise integers in a while loop in a range
body: <p>guys!</p>
  <p>I am trying to do assessment task. It requires me to input number of branches for certain subjects ( Chemistry, Computers, Biology, Physics, Arts). Then it asks me to put number of books for these subjects per branch. Then it asks me to calculate the number of books as total and calculate the average. I am almost done with it but there is one last obstacle for me - how to calculate sum of books in these branches and subjects. I would really appreciate if you explain it to me.</p>
  <p>Here is the code:</p>
  <pre><code>#!/usr/bin/env python3
  
  branches = 0
  while branches &lt; 1:
    try:
      branches = int(input(&quot;Enter branches: &quot;))
    except (ValueError, TypeError):
      print(&quot;Number of branches must be an integer&quot;)
    else:
      if branches &lt; 1:
        print(&quot;Number of branches must be at least 1&quot;)
  
  
  
  for i in range(branches):
    for category in [&quot;Computer&quot;, &quot;Physics&quot;, &quot;Chemistry&quot;, &quot;Biology&quot;, &quot;Arts&quot;]:
      books = -1
      while books &lt; 0:
        try:
          string_branches = str(i+1)
          books = int(input(&quot;Enter the number of books for &quot; + category +  &quot; of branch &quot; + string_branches + &quot; :&quot; ))
        except (ValueError, TypeError):
          print(&quot;Number of books must be an integer&quot;)
        else:
          if books &lt; 0:
            print(&quot;Number of books must be at least 1&quot;)
          books_total = 0
          books_total = books + books 
  books_per_category = books_total  / branches
  print(&quot;Following the information of all the branches of the main library: &quot;)
  print(&quot;Total number of books: &quot;,books_total )
  print(&quot;Average numbers of books per category: &quot;,  books_per_category)
  </code></pre>
  <p>The million dollar question is - how to make books add up to total? Believe me i ve tried like bunch of different methods, but they seem not to work.</p>
  <p>Maybe i did not define function of something.</p>