no "\n" but new line being made?
<p>There is no <code>\n</code> in my code but when I print out all my variables, it creates a newline meaning my last variable is printed on another line.</p>

<p>my code :</p>

<pre><code>with open("read_it.txt", "r") as text_file:
    for items in text_file:
        line = items.split(",")
        if GTIN in items:
           product = line[1]
           indprice = line[2]
           finprice = float(indprice)* float(Quantity)
           print(GTIN,product,Quantity,"Â£",indprice,"Â£",finprice)
</code></pre>

<p>current output (wrong) :</p>

<pre><code>086947367 banana 2 Â£ 0.50
 Â£ 1.0
</code></pre>

<p>I want :</p>

<pre><code>86947367 banana 2 Â£ 0.50 Â£ 1.0
</code></pre>

<p>any help appreciated.</p>

<p>When you call readline on a file object (which you're doing implicitly in your for loop), it leaves the trailing '\n' and/or '\r' characters.  In this case, your indprice variable still contains that trailing '\n'.</p>

<p>Try:</p>

<pre><code>line = items.strip('\r\n').split(',')
</code></pre>

<p>Or, if it's a small text file that you can pull entirely into memory:</p>

<pre><code>for items in text_file.read().split('\n'):
</code></pre>

python python-3.x