title: How would I read only the first word of each line of a text file?
body: <p>I wanted to know how I could read ONLY the FIRST WORD of each line in a text file. I tried various codes and tried altering codes but can only manage to read whole lines from a text file.
  The code I used is as shown below:</p>
  
  <pre><code>QuizList = []
  with open('Quizzes.txt','r') as f:
              for line in f:
                  QuizList.append(line)
          line = QuizList[0]
          for word in line.split():
              print(word)
  </code></pre>
  
  <p>This refers to an attempt to extract only the first word from the first line. In order to repeat the process for every line i would do the following:</p>
  
  <pre><code>QuizList = []
  with open('Quizzes.txt','r') as f:
              for line in f:
                  QuizList.append(line)
  capacity = len(QuizList)
  capacity = capacity-1
  index = 0
  while index!=capacity:
      line = QuizList[index]
      for word in line.split():
          print(word)
          index = index+1
  </code></pre>