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>It is pretty 'common' 'problem', and it is often solved by using ''.join method. I assume that you've a list of integers, so all you need to do is:</p>

<pre><code>powers = [10, 7, 6, 4]
print(' + '.join(['2 ** {n}'.format(n= n) for n in powers]))
</code></pre>

python python-3.x printing