title: Finding average in .txt file python
body: <p>i need to print out average height from a .txt file. How do I write it in an easy way? The .txt file has these numbers:</p>
  
  <pre><code>12
  14
  59
  48
  45
  12
  47
  65
  152
  </code></pre>
  
  <p>this is what i've got so far:</p>
  
  <pre><code>import math
  
  text = open(r'stuff.txt').read()
  data = []
  with open(r'stuff.txt') as f:
      for line in f:
          fields = line.split()
          rowdata = map(float, fields)
          data.extend(rowdata)
  
  biggest = min(data)
  smallest = max(data)
  print(biggest - smallest)
  </code></pre>