What Is The Python 3 Equivalent to This
<p>What is the Python 3 equivalent to Python 2's statement:</p>

<pre><code>print x,
</code></pre>

<p>I am aware of Python's 3</p>

<pre><code>print(x,end=' ')
</code></pre>

<p>However this is not exactly the same as I will demonstrate.</p>

<p>So lets say I had a list of items I wanted to print out all on one line with spaces in between each item BUT NOT after the last item.</p>

<p>In Python 2 it is just simply:</p>

<pre><code>for x in my_list:
    print x,
</code></pre>

<p>However if we use the Python 3 approach above it will produce the list of items on one line but will have trailing white space after the last item.</p>

<p>Does Python 3 have a nice elegant solution to produce the same results as in the Python 2 statement?</p>

<p>Unless you need to print each element on their own, you can do:</p>

<pre><code>print(' '.join(my_list))
</code></pre>

<p>or</p>

<pre><code>print(*my_list)
</code></pre>

python printing trailing