title: Python: Evenly space output data with varying string lengths
body: <p>I am trying to get my output data to look like this:</p>
  
  <pre><code>-------------------------------------------------------
              Grade Report for Programs 
  -------------------------------------------------------
  Jacobson, Mark      19.0 &lt;--- 20,17,20
  Snurd, Mortimur     16.5 &lt;--- 20,19,18,17,16,15,14,13
  Luxemburg, Rosa     15.0 &lt;--- 18,15,20,10,12
  Atanasoff, John     20.0 &lt;--- 20,20,20,20,20,20,20
  Hopper, Grace       20.0 &lt;--- 20,20,20,20,20,20
  -------------------------------------------------------
  </code></pre>
  
  <p>But I don't know how to deal with the varying name length. My output currently looks like this.</p>
  
  <hr>
  
  <pre><code>            Grade Report for Programs 
  -------------------------------------------------------
  Jacobson, Mark   19.0 &lt;--- 20,17,20
  Snurd, Mortimur   16.5 &lt;--- 20,19,18,17,16,15,14,13
  Luxemburg, Rosa   15.0 &lt;--- 18,15,20,10,12
  Atanasoff, John   20.0 &lt;--- 20,20,20,20,20,20,20
  Hopper, Grace   20.0 &lt;--- 20,20,20,20,20,20
  -------------------------------------------------------
  </code></pre>
  
  <p>The program I have written is to take an input file of grade scores and collect the data and neatly print out the average.</p>
  
  <p>The input file looks something like this:</p>
  
  <pre><code>Mark Jacobson,20,17,20
  Mortimur Snurd,20,19,18,17,16,15,14,13
  Rosa Luxemburg,18,15,20,10,12
  John Atanasoff,20,20,20,20,20,20,20
  Grace Hopper,20,20,20,20,20,20
  </code></pre>
  
  <p>And here is my code that collects the name and scores, and prints out the data with last name, first name, average score, then the actual scores that resulted to the average.</p>
  
  <pre><code>file = input("Enter filename: ")
  
  grade_file = open(file, 'r')
  
  print()
  
  print('---------------------------------------------------------')
  print('\t\tGrade Report for Programs')
  print('---------------------------------------------------------')
  
  for text in grade_file:
      end_of_name = text.find(',')
      name_seperated = text.find(' ')
  
      first_name = text[0:name_seperated]
      last_name = text[name_seperated+1:end_of_name]
  
      name_last_first = last_name + "," + " " + first_name
  
      grades = text[end_of_name+1:]
  
      start = 0
      index = 0
      sum_n = 0
      average= 0
      score = 0
      count = 0
  
      while index &lt; len(grades):
          if grades[index] == ',':
              score = int(grades[start:index])
              count += 1
              sum_n = score + sum_n
              start = index + 1
          index += 1
  
      count += 1       
  
      score = int(grades[start:index])
      sum_n = score + sum_n
      average = sum_n / count
  
  
  
      print(name_last_first, " ", average, "&lt;---", grades)
  
  
  print('---------------------------------------------------------')
  
  
  grade_file.close()
  </code></pre>
  
  <p>I just need to figure out how to have even spaces so it makes an even row and column like the first output. Help is greatly appreciated! Thanks!</p>