Adding horizontal space between data on a Read only script
<p>I need my output to look nice, and it looks very sloppy. </p>

<p>--------Current output---------</p>

<pre><code>Below are the players and their scores

John Doe 120
Sally Smooth 115
</code></pre>

<p>----------End current output----------</p>

<p>My desired output follows</p>

<p>-------Desired output-----------------</p>

<pre><code>Below are the players and their scores

John Doe         120
Sally Smooth     115
</code></pre>

<p>--------End desired output-------------</p>

<p>my current code follows;</p>

<pre><code>def main():

     # opens the "golf.txt" file created in the Golf Player Input python
     # in read-only mode
     infile = open('golf.txt', 'r')

     print("Below are the players and their scores")
     print()

     # reads the player array from the file
     name = infile.readline()

     while name != '':

          # reads the score array from the file
          score = infile.readline()

          # strip newline from field
          name = name.rstrip('\n')
          score = score.rstrip('\n')
          # prints the names and scores
          print(name + " " + score)

          # read the name field of next record
          name = infile.readline()

     # closes the file    
     infile.close()


 main()
</code></pre>

<p>Try using the tab character to format your spaces better.</p>

<pre><code>print(name + "\t" + score)
</code></pre>

<p>This should give you something closer to your desired output. But you may need to use two if some names are long.</p>

python readfile