title: Using a data text file in Colab to calculate mean
body: <p>I am new to python so any assistance is greatly appreciated.
  I am writing a calculator to generate mean from a text file in google colab.</p>
  <p>I am able to calculate the mean by hardcoding numbers, and I am also able to access a text file in a separate piece of code.
  My issue is passing the data in the txt file to the mean function.</p>
  <pre><code>'''
  ####This writes data in from txt file
  filename = '/content/drive/MyDrive/ColabNotebooks/data.txt' 
  
  with open(filename) as file_object:
      lines = file_object.readlines()
      
  for line in lines:
     print(line)
  '''
  
  
  '''
   #Calculating the Mean
  def calculate_mean(numbers):
    s=sum(numbers)
    N=len(numbers)
  # Calculate the mean
    mean=s/N
  
    return mean
  
  if __name__=='__main__':
    
    donations =[100,100,200,1000]
    mean=calculate_mean(donations)
    N= len(donations)
    print('Mean donation over the last {0} days is {1}'.format(N,mean))
  '''
  </code></pre>
  <p>Question
  how do i modify 'donations' to obtain the list from the text file data.txt instead of the hardcoded values</p>
  <p>Here is a screenshot of values in the txt file.  This is a learning exercise for me.
  <a href="https://i.stack.imgur.com/pIyaY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pIyaY.png" alt="data" /></a></p>
  <p>Again many thanks!</p>