How To Print Text In Next Line Or New Using Python

In this tutorial, learn how to print text in the next line to add a line break in a string in Python. The short answer is to use the symbol \n to add the new line character using Python. You can add a string break in string text or string characters using this method.

If you use the print function to print the string in the output. All the string text content are not suitable to print in the same line. In that case, you have to write another print function to get the output in the new line. However, in many programming languages, you can add the newline character(\n) to add line breaks in the string.

Let’s find out below with the examples you can check to print text in the new line in Python.

Output Without Adding Line Breaks in Python

Let us first see the example showing the output without using the newline character. It prints the whole text in the same single line. See the example to print your text in the same line using Python.

Output

How are you? I am fine thank you.

The above example showing the output containing the text content in the same line. However, in this string text, text content should be in the new line. To get the required text in the next line, you have to use the below-given example.

How To Print Text In Next Line Or New Using Python

Bonus: download a Free Python cheat sheet that will show you 20+ most important examples to learn in Python.

How to Print Text In Next Line Using \n With Python

If you want to print the required text content in the new line in Python. You have to use the \n newline character in the place where you want the line break. Put as many newline characters in the text content as you want. There is no limit to place the number of \n in the text content.

Output

How are you?
I am fine thank you.

The above example using the single symbol \n in the text content. The above example using the print() to display the text content. It contains a single line break using \n. However, you can add as many line breaks as per your requirements.

DOWNLOAD Free PYTHON CHEAT SHEET

You may also like to read