title: How to save results in txt file but not the same like print?
body: <p>Hi with this code I get numbers.</p>
  
  <pre><code>n = 1000
  
  while n &gt; 500:
      print(n, end=', ')
      n -= 50
      print(n)
      n -= 100
  </code></pre>
  
  <p>I get this result</p>
  
  <pre><code>1000, 950
  850, 800
  700, 650
  550, 500
  </code></pre>
  
  <p>How I can save this in txt but this way? First number to be second and second to be first.</p>
  
  <pre><code>950, 1000
  800, 850
  650, 700
  500, 550
  </code></pre>
  
  <p>I tried this but not work</p>
  
  <pre><code>f = open("test.txt", 'w')
  print(n, end=', ', file=f)
  print(n, file=f)
  f.close() 
  </code></pre>
  
  <p>And tried this</p>
  
  <pre><code>with open("test.txt", 'w') as f:
     print('Filename:', filename, file=f)
  </code></pre>
  
  <p>Can someone to help me?    </p>