iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Python syntax is easier to read when you recognize the jobs punctuation and whitespace do together. Parentheses, square brackets, and curly braces can all group code, but they serve different common roles; a colon can introduce a code block or separate a dictionary key from its value; and indentation determines which statements belong to a block.
This guide is a quick reference for programmers who are new to Python. The official Python Tutorial is aimed at people who already know programming concepts, rather than those learning programming from scratch.
What do the brackets mean in Python?
Python has three common delimiter pairs: parentheses (), square brackets [], and curly braces {}. Their roles depend on context, so use the surrounding syntax to tell them apart.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems| Delimiters | Common roles | Example |
|---|---|---|
() |
Group an expression, enclose a function call’s arguments, or appear in tuple and generator-expression syntax. | print(value) calls a function; (2 + 3) * 4 groups an expression. |
[] |
Delimit a list display or list comprehension; also used for indexing and slicing. | colors = ["red", "blue"] creates a list; colors[0] accesses an item. |
{} |
Delimit a dictionary or set display. | {"mode": "quick"} is a dictionary; {"red", "blue"} is a set. |
A pair of delimiters does not always create a collection: parentheses can simply group an expression, and square brackets can select part of an existing value. The exact role is determined by the expression around them.
#1 Best Overall
Parentheses group expressions, calls, and tuples
In print(message), parentheses enclose the argument to a function call. In (2 + 3) * 4, they make the addition happen as a group before the multiplication. Parentheses can also enclose a tuple or a generator expression.
A tuple is determined by its commas, not merely by round brackets. ("x") is a grouped string expression; ("x",) is a one-item tuple. The comma makes the difference. The empty tuple is the exception: () creates it.
Rank #2
Square brackets make lists and access items
Commas separate values in a list display, as in ["alpha", "beta"]. Square brackets also appear in subscriptions, such as items[0], and slices, such as items[1:3]. In the latter, the colon separates slice bounds rather than introducing a code block.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Curly braces make dictionaries and sets
A dictionary display contains key:value pairs separated by commas: {"mode": "quick", "count": 2}. The colon separates each key from its value. Curly braces can also enclose comma-separated set elements, as in {"alpha", "beta"}. Empty braces, {}, create an empty dictionary, not an empty set.
Why do I need a colon after an if statement?
A colon at the end of a compound-statement header introduces its suite—the statement or statements controlled by that header. You need one after headers such as if, for, while, and def. The same punctuation has other roles elsewhere: in a dictionary display it separates a key from its value, and in a slice it separates bounds.
For example, if ready: ends the condition header and begins the suite. A suite can be a simple statement on the same line, but ordinary multi-statement blocks use subsequent, indented lines. Nested compound statements require the indented form. See the Python compound-statement reference for the formal rules.
Why is indentation important in Python?
Leading whitespace is part of Python’s structure, not just a visual aid. A change in indentation level starts or ends a block: increasing indentation begins a suite, and returning to an earlier level ends it. A dedent must return to a prior indentation level. The lexical reference describes these transitions as INDENT and DEDENT tokens.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Use one consistent indentation style in a file. Python expands tabs to tab stops when calculating indentation; inconsistent mixtures of tabs and spaces can raise TabError. Mixed whitespace does not invariably fail, but avoiding it prevents ambiguity across editors and environments. The lexical analysis reference documents indentation and line-joining rules.
Best Value
How do brackets and alignment work together on multiple lines?
When an expression is inside an open parenthesis, square bracket, or curly brace, Python allows it to continue across physical lines without a backslash, provided the delimiters are properly matched. Indentation inside the expression can make the items easier to scan; the delimiter marks the continuation, while the indented block under a compound header is controlled by indentation.
if ready:
items = [
"alpha",
"beta",
]
settings = {
"mode": "quick",
"count": 2,
}
Here, if ready: introduces a suite, and the statements in that suite are indented consistently. The square brackets enclose a list; the curly braces enclose dictionary key:value pairs. Each collection spans several lines because its opening delimiter has not yet been matched by a closing one.
Keep the brackets balanced when wrapping an expression. A missing closing delimiter prevents Python from recognizing where the expression ends, and implicit continuation applies only within parentheses, square brackets, or curly braces—not to an arbitrary line break.
Quick checks for reading Python punctuation
- If a line ends in a compound-statement header such as
if condition:, look for the indented suite below it. - If a colon appears between a key and a value inside curly braces, it is dictionary punctuation, not a block header.
- If you see parentheses around one value, check for a comma before deciding it is a tuple.
- If an expression wraps across lines, check that its opening and closing delimiters match.
- If a block appears misaligned, compare the leading whitespace with earlier indentation levels and use a consistent tabs-or-spaces style.
For more depth after this reference, the official tutorial notes that it can be read offline and points readers toward books for further study; a beginner Python programming book is optional, not a prerequisite for using the syntax examples here.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

