title: how to add thousands separator to a number that has been converted to a string in python?
body: <p>in my scenario (python 2.7), i have:</p>
  
  <p><code>str(var)</code></p>
  
  <p>where var is a variable that sometimes requires thousands separators eg 1,500 but as you can see has been converted to a string (for concatenation purposes).  </p>
  
  <p>i would like to be able to print out that variable as a string with thousands separators.  </p>
  
  <p>i have read solutions for adding formatting to a number eg:</p>
  
  <pre><code>&gt;&gt;&gt; '{:20,.2}'.format(f)
  '18,446,744,073,709,551,616.00'
  </code></pre>
  
  <p>from <a href="https://stackoverflow.com/a/1823189/1063287">https://stackoverflow.com/a/1823189/1063287</a></p>
  
  <p>but this seems to be applicable just for a number, not for a number that has been converted to a string.  </p>
  
  <p>thank you.  </p>
  
  <p><strong>edit:</strong>  for more specific context, here is my implementation scenario:</p>
  
  <pre><code>print 'the cost = $' + str(var1) + '\n'
  print 'the cost = $' + str(var2) + '\n'
  </code></pre>
  
  <p>and i have several 'vars'.  </p>