Newline

noun

say it: “NOO-lyne” /ˈnuˌlaɪn/

The invisible character that ends a line of text and starts the next, written \n in Python; print() adds one at the end by itself.

What is a newline?

A newline is the invisible character that ends a line of text. In code it is written \n. print() adds one at the end for you.

print("Apples\nBananas")
# Apples
# Bananas

In a sentence

  • “The receipt string uses a newline between items so each prints on its own line.”
  • “Each line read from the file ended with a newline, so strip() was needed before comparing names.”

Level: Novice · More Python terms at this level

Updated