title: Finding total and average salaries from 1000 lines of text
body: <p>I need to write a python program that reads 1000 lines of text and take the total and average of the salaries of each professor category (assistant, associate, full, all faculty). Here is the problem:</p>
  
  <blockquote>
    <p>A university posts its employee salary at
    <a href="http://cs.armstrong.edu/liang/data/Salary.txt" rel="nofollow">http://cs.armstrong.edu/liang/data/Salary.txt</a>. Each line in the file
    consists of faculty first name, last name, rank, and salary (see
    Exercise 13.16). Write a program to display the total salary for
    assistant professors, associate professors, full professors, and all
    faculty, respectively, and display the average salary for assistant
    professors, associate professors, full professors, and all faculty,
    respectively.</p>
  </blockquote>
  
  <p>This is the code I have so far:</p>
  
  <pre><code>import urllib.request
  
  def main():
      infile = urllib.request.urlopen('http://cs.armstrong.edu/liang/data/Salary.txt')
      s = infile.read().decode().splitlines()
  
      asstTotal = 0
      asstCount = 0
      asscTotal = 0
      asscCount = 0
      fullTotal = 0
      fullCount = 0
  
      for line in s:
          if "assistant" in line:
              asstCount += 1
              asstTotal += int(float(s[3]))
  
          if "associate" in line:
              asscCount += 1
              asscTotal += int(float(s[3]))
  
          if "full" in line:
              fullCount += 1
              fullTotal += int(float(s[3]))
  
      allFacTotal = asstTotal + asscTotal + fullTotal
      avgAsst = int(asstTotal / asstCount)
      avgAssc = int(asscTotal / asscCount)
      avgFull = int(fullTotal / fullCount)
      avgAll = int(allFacTotal / 1000)
  
      print("Total assistant professor salary is", asstTotal)
      print("Total associate professor salary is", asscTotal)
      print("Total full professor salary is", fullTotal)
      print("Total faculty salary is", allFacTotal)
      print("Average assistant professor salary is", avgAsst)
      print("Average associate professor salary is", avgAssc)
      print("Average full professor salary is", avgFull)
      print("Average faculty salary is", avgAll)
  
  main()
  </code></pre>
  
  <p>I'm not sure how to get the salaries from the respective professor ranks and totaling and averaging them. Any input would be much appreciated!</p>
  
  <p>Result:</p>
  
  <pre><code>Total assistant professor salary is 24306418
  Total associate professor salary is 27235856
  Total full professor salary is 27631726
  Total faculty salary is 79174000
  Average assistant professor salary is 79174
  Average associate professor salary is 79174
  Average full professor salary is 79174
  Average faculty salary is 79174
  </code></pre>