delete space in one line prints
<p>How to remove spaces in this print ?</p>

<p>For example</p>

<pre><code>for i in range(5):
print i,
</code></pre>

<p>Will prints: 1 2 3 4 5</p>

<p>But I would like to get print like: 12345</p>

<p>Someone can help ?</p>

<p>In Python 3, you can use:</p>

<pre><code>for i in range(5):
    print(i, end="")
</code></pre>

<p>In Python 2, however you can not achieve it via simple print. There are two ways to do it:</p>

<pre><code># Way 1: Using "sys.stdout". But this will write to stdout 
&gt;&gt;&gt; import sys
&gt;&gt;&gt; for i in range(5):
...     sys.stdout.write(str(i))
... 
01234&gt;&gt;&gt;

# Way 2: Convert it to list of string and then join them
&gt;&gt;&gt; print ''.join(map(str, range(5)))
01234
</code></pre>

python printing spaces