title: Python; If statements, For Loops, File Reading
body: <p>To be clear, I am not asking anyone to do this for me. I am simply asking a question seeking guidance so I can continue working on this.</p>
  
  <p>We are given a file that gives various weights of packages;</p>
  
  <pre><code>11
  25
  12
  82
  20
  25
  32
  35
  40
  28
  50
  51
  18
  48
  90
  </code></pre>
  
  <p>I have to create a program that will count the amount of packages, Categorize them into Small, Medium, and Large, and find the average of the weights.
  I know I have to use If statements, and for loops to accumulate the weight count and categorize them among each category.</p>
  
  <p>The terms for what is small, med, and large is as follows;</p>
  
  <p>Small &lt; 10 lbs</p>
  
  <p>Medium >= 10 lbs. and &lt; 30 lbs</p>
  
  <p>Large >= 30 lbs.</p>
  
  <p>If no packages of a weight
  class are entered, report the message “N/A” instead of an average (if you try to
  divide by 0 you will get an exception).</p>
  
  <p>This is the code I have so far, I cant figure out if I have to include a for loop after the if, elif, and else. Or if what I have is on track.</p>
  
  <pre><code>infile = open("packages.txt", 'r')
  count = 0
  line = infile.readline()
  weight = int(line)
  for line in infile:
      if weight &lt; 10:
          count = count + 1
          weight = weight + int(line)
          while weight &lt; 10:
              try:
                  avg = weight / count
              except ValueError:
                  print("N/A")
      elif weight &gt;= 10:
          if weight &lt; 30:
              weight = weight + int(line)
              count = count + 1
              avg = weight/count
      else:
          weight = weight + int(line)
          count = count + 1
          avg = weight/count
  </code></pre>
  
  <p>The output has to look something like this</p>
  
  <pre><code>Category    Count    Average
  Small       0        N/A
  Medium      7        19.9
  Large       8        53.5
  </code></pre>
  
  <p>Again, I am not looking for someone to do this for me. I am looking for the next step and/or tweaks to what I currently have to be able to continue forward. Thank you!</p>