Member-only story

Python Newline: How to Add a New Line and Print Without Newline | Python Tutorial

Printing a new line in Python

Sanjay Priyadarshi
5 min readOct 12, 2022
Photo by Tai Bui on Unsplash

Python programmers sometimes need to print some “non-printable” characters.

Include things like a tab or a new line.

To do so, we need to use the backslash character (\) to escape characters. If you do it without the backslash character, it will have a different meaning.

An example

If you want to print a tab, you will use the backslash character just before the letter t, like this: \t.

If you don’t use the backslash character before the letter t, only the letter t will be printed. In this case, no tab will be printed.

print('HellotPython')print('Hello\tPython')
//Output
HellotPythonHello Python

Python new line

When you break lines and print content on a new line, the readability of the output is greatly improved.

Whether you write code in Javascript, Python, C++, or Java, the readability of the output is important.

--

--

Sanjay Priyadarshi
Sanjay Priyadarshi

Written by Sanjay Priyadarshi

Join a Community of People Who Love Javascript, Programming and Technology — codertoentrepreneurs.substack.com

No responses yet