title: Directing print output to a .txt file
body: <p>Is there a way to save all of the print output to a txt file in python? Lets say I have the these two lines in my code and I want to save the print output to a file named <code>output.txt</code>.</p>
  
  <pre><code>print ("Hello stackoverflow!")
  print ("I have a question.")
  </code></pre>
  
  <p>I want the <code>output.txt</code> file to to contain</p>
  
  <pre class="lang-none prettyprint-override"><code>Hello stackoverflow!
  I have a question.
  </code></pre>