Eunice Wanja
last year
Eunicecountry asked

Do you use newline on a string only?

Abhilekh Gautam
Expert
last year

The newline character \n is mostly used in strings to create line breaks. When you include \n in a string, it tells Python to start a new line.

For example:

print("Hello\nWorld!")

This will output:

Hello
World!

If you have any more questions, feel free to ask—I’m happy to assist!

Python
This question was asked as part of the Getting started with Python course.