title: Python 3.5 - Output from file
body: <p>My goal is to have two programs. One will ask the user to input a test name and then a test score repeatedly until the user hits enter. This information will be stored in a .txt file. The second program will pull the information from the .txt file and print it into a format like something below with the test scores and a final average:</p>
  
  <pre><code>Reading six tests and scores
  TEST          SCORE
  objects       88
  loops         95
  selections    86
  variables     82
  Average Test Score is 
  </code></pre>
  
  <p>So far I have this for the first program to generate the txt document:</p>
  
  <pre><code>def main():
      myfile = open('test.txt', 'w')
      test = input('Please enter test name or enter to quit ')
  
      while test != '':
          score = int(input('Enter % score on this test '))
          myfile.write(test + '\n')
          myfile.write(str(score) + '\n')
          test = input('Please enter test name or enter to quit ')
  
      myfile.close()
      print('File was created successfully')
  
  main()
  </code></pre>
  
  <p>The second program looks like this and is in rough shape:</p>
  
  <pre><code>def main():
      f = open('test.txt', 'r'); 
      text = f.read(); 
      f.close()
  Main()
  </code></pre>
  
  <p>Any suggestions or examples? I’m really struggling. </p>