title: Python- Writing all results from a loop to a variable
body: <p>I have a <code>.txt</code> file with dozens of columns and hundreds of rows. I want to write the results of the entirety of two specific columns into two variables. I don't have a great deal of experience with for loops but here is my attempt to loop through the file.</p>
  
  <pre><code>a = open('file.txt', 'r') #&lt;--This puts the file in read mode
  
  header = a.readline() #&lt;-- This skips the strings in the 0th row indicating the labels of each column
  
  for line in a:
      line = line.strip() #removes '\n' characters in text file
      columns = line.split() #Splits the white space between columns
      x = float(columns[0]) # the 1st column of interest  
      y = float(columns[1]) # the 2nd column of interest
      print(x, y)
  f.close()
  </code></pre>
  
  <p>Outside of the loop, printing <code>x</code> or <code>y</code> only displays the last value of the text file. I want it to have all the values of the specified columns of the file. I know of the append command but I am unsure how to apply it in this situation within the for loop.</p>
  
  <p>Does anyone have any suggestions or easier methods on how to do this?  </p>