title: Saving python print output to variable
body: <p>i'm trying to print a message on the screen and then also save that in a text file, but if i put it into a variable first, then print it, it displays with things like, and () which i don't want. I'm wondering how I would save the print output to a variable, so that i can then write it to a text file.</p>
  
  <pre><code>print("P", count, ": ", "".join(random.choice(chars) for i in range(length)))
  </code></pre>
  
  <p>That is what i have the print as, but if i did this:</p>
  
  <pre><code>var = "P", count, ": ", "".join(random.choice(chars) for i in range(length))
  </code></pre>
  
  <p>it would display as this V which I dont want it to.</p>
  
  <pre><code>('P ', 314, ': ', 'ZYIAV')
  </code></pre>