Learn to use print multiple items in the same line on the console screen in Python. Learn to prevent print statements to print in new line each time.

When you use two or more print statements in Python, each time, the contents are printed in a new line as demonstrated by following code and its console output.

Output.

WTMatter
Gurmeet Singh

But now the issue is what if we do not want to print the contents of the second print statement in another line? That’s all we’re going to figure out in this tutorial.

Table of Contents

Ways To Print in the same line (Without New Line Breaks)

There are multiple ways in Python using which you can print multiple contents without new line breaks, in the same line using either a single or multiple print statements. Two methods are illustrated below with the help of examples.

Method 1 (Different for Version 2.X and 3.X)

This method is different for version 2.X and 3.X. In Version 2.X, all you need do is to use a comma after the print statement to avoid the line break. This will print the contents that the statement without the new line. If you use multiple print statements and separate them with commas, then the contents will although be printed in the same line yet will be separated with whitespace.

For the same purpose in versions 3.X, you need to specify the end character of the line using the end argument passed to the print statement.

#programming #python #new line #python tutorial

Print Without Newline in Python (Print in the same line) - WTMatter
2.45 GEEK