How to get rid of extra + sign in print statement, Python
<pre><code>print('2**', n, ' + ', sep='', end='')
</code></pre>

<p>Hi the print statement above is in a loop so the output ends up being </p>

<pre><code>2 ** 10 + 2 ** 7 + 2 ** 6 + 2 ** 4 + 2 ** 1 +
</code></pre>

<p>I need to get rid of the last plus in the statement but have no idea how to go about doing so.</p>

<p>You can store the string to be printed in a variable in the loop and then after the loop ends, remove the extra plus by slicing using <code>to_print[:len(to_print)-1]</code>
And then print to_print.
Here to_print is the text you need to store in the loop Instead of printing it and then print it at the end after slicing it as I showed above.</p>

python python-3.x printing