title: How to remove last comma from print(string, end=“, ”)
body: <p>my output from a forloop is </p>
  
  <pre><code>string = ""
  for x in something:
     #some operation
     string =  x += string 
  
  print(string)
  
  5
  66
  777
  </code></pre>
  
  <p>I use the below code to have them on the same line </p>
  
  <pre><code>print(string, end=", ")
  </code></pre>
  
  <p>and then I get</p>
  
  <pre><code>5, 66, 777,
  </code></pre>
  
  <p>I want the final result to be</p>
  
  <pre><code> 5, 66, 777
  </code></pre>
  
  <p>How do I change the code <code>print(string, end=", ")</code> so that there is no <code>,</code> at the end </p>
  
  <p>The above string is user input generated it can me just <code>1</code> or <code>2,3, 45, 98798, 45</code> etc</p>
  
  <p><strong>So far I have tried</strong></p>
  
  <pre><code>print(string[:-1], end=", ")                   #result = , 6, 77, 
  print((string, end=", ")[:-1])                 #SyntaxError: invalid syntax  
  print((string, end=", ").replace(", $", ""))   #SyntaxError: invalid syntax  
  print(", ".join([str(x) for x in string]))     # way off result 5
                                                                  6, 6
                                                                      7, 7, 7
      print(string, end=", "[:-1])                  #result 5,66,777,(I thought this will work but no change to result)
     print(*string, sep=', ')                          #result 5
                                                               6, 6
                                                               7, 7, 7 
  </code></pre>
  
  <p>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
  
  <pre><code>user input
  twenty five, four, nine 
  </code></pre>
  
  <p>gets </p>
  
  <pre><code>25, 4, 9, #(that stupid comma in the end)
  </code></pre>