Skip to content
FollowtheDamnCode

print()

Showing text and numbers, with sep, end, and escape sequences.

4 minute read

Big idea

print() shows things on the screen. Put what you want to show between the parentheses.

The idea

print("Hello, World!")
  • print — the name of a built-in function (a ready-made action).
  • ( ) — what you hand to the function goes inside.
  • "Hello, World!" — a piece of text, called a string. Strings go in quotes.

Each print ends with a new line, so the next one starts on a fresh line.

Try it — edit it and run it again
print("Hello, World!")
print("Python is fun.")
output
Hello, World!
Python is fun.

Run and edit it in the app.

Printing numbers and sums

Numbers don't need quotes. Python works out the maths before printing:

Predict: what gets printed?
print(7)
print(7 + 3)
print("7 + 3")
What does it print? Show the answer
7
10
7 + 3

Run and edit it in the app.

The third line is in quotes, so it's text — Python prints it exactly as written and does no maths.

Several things at once

Separate values with commas. print puts a space between them:

print("I am", 12, "years old")    # I am 12 years old

Two optional settings change that:

  • sep="..." — what goes between the values (default: a space).
  • end="..." — what goes at the end (default: a new line, written "\n").
sep and end
print("2026", "10", "03", sep="-")
print("Loading", end="")
print("...", end="")
print(" done!")
output
2026-10-03
Loading... done!

Run and edit it in the app.

Watch it

Special characters

Inside a string, a backslash starts an escape sequence:

  • \n — new line
  • \t — tab
  • \" — a double quote inside a double-quoted string
  • \\ — a real backslash
Fix the bug: print the sentence with its quote marks
print("She said "hi" to me")
output
She said "hi" to me

Run and edit it in the app.

Two ways to fix it: escape the inner quotes (\"hi\"), or wrap the whole string in single quotes: 'She said "hi" to me'. Python accepts either kind of quote, as long as both ends match.

What does print("a", "b", "c", sep="") show?

Think of it like

A label maker. You type the words, press print, and out comes a label. sep is the gap between words; end decides whether it cuts the tape (new line) or keeps going.

Common mistake

Forgetting a quote or a bracket:

print("Hello)     # ✗ SyntaxError: unterminated string literal
print("Hello"     # ✗ SyntaxError: '(' was never closed
print("Hello")    # ✓

Key terms

  • print() — Shows values on the screen.
  • String — A piece of text in quotes.
  • Escape sequence — A backslash code like \n for characters you can't type directly.

Check yourself

What does print(3 + 4) show?

Which setting changes what print puts at the end of the line?

What does \n mean inside a string?