print()
print() is a built-in Python function that shows a value on the screen, and it is the first line most programs start with.
Last updated: 30 Sep, 2026 · Python 3.14
A program is a list of instructions that Python runs from top to bottom. print is how you see what those instructions did.
Syntax:
print(value) # one value
print(value1, value2) # several, separated by a spacePrinting a line of text
print("Hello!")Hello!
print shows whatever is inside its brackets. The quotes mark Hello! as text, so Python shows it as it is instead of trying to run it.
Two lines run in the order they are written, and each print starts a new line.
print("Ticket 1: I was charged twice for one order")
print("Ticket 2: My parcel has not arrived")Ticket 1: I was charged twice for one order Ticket 2: My parcel has not arrived
Printing text and sums
Without quotes, Python works the value out before printing it. With quotes, it is only text that happens to contain a sum.
print(2 + 3)
print("2 + 3")5 2 + 3
Adding comments
A # starts a comment. Python ignores everything from there to the end of the line, so comments are notes for whoever reads the code next.
# Tickets that came in overnight
print("Waiting: 3") # this part is ignored tooWaiting: 3
Reading your first error
Leave out the closing quote and Python cannot tell where the text ends. It stops before running anything and says so.
print("Hello!) File "main.py", line 1
print("Hello!)
^
SyntaxError: unterminated string literal (detected at line 1)Read the last line of an error first. It names the kind of problem. The lines above it say where: the file and the line number. On your computer the error shows the full path of your file instead of main.py, and often a row of ^ marks under the exact spot; the last line is the same.
Errors are normal. Most lessons cause one deliberately, because an error you have seen once is easy to recognise the next time.
Text in quotes vs a value
| You write | print shows | Why |
|---|---|---|
print(2 + 3) | 5 | Python works out the sum first |
print("2 + 3") | 2 + 3 | Quotes make it text |
Where print() helps in AI code
- Checking what a model sent back before your program uses it.
- Following a long run step by step, one line per ticket.
Print("Hello") with a capital P is a NameError. Python is case sensitive: print and Print are different names.Related
- Previous: Installation and setup
- Next: Variables
- Reference: print() in the Python docs
- Print your own name.
- Print
10 - 4with quotes and without them. - Delete the closing bracket of a
printand read the last line of the error.
You understood something today that you didn't yesterday.