Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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

Use print(items) to display a Python list with its brackets and string quotes. To change how it looks, print each item on its own line, add index numbers with enumerate(), separate items without brackets, or use pprint for nested data.

Print the whole list with its brackets

Call print() with the list variable:

colors = ['red', 'green', 'blue']
print(colors)

Output:

['red', 'green', 'blue']

The brackets and quotes are part of the list’s displayed representation. For an ordinary list of built-in values, str() and repr() often produce the same-looking output, though they serve different purposes: str() is intended to be fairly human-readable, while repr() aims for a representation the interpreter can read. See the Python tutorial’s discussion of input and output.

Print each item on a new line

Loop over the list and call print() once for each element:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
for color in colors:
    print(color)

Each call adds a newline by default, so the result is one item per line. Iterating directly over a list gives you its elements in list order; the Python tutorial covers list operations and sequence iteration.

Print list items with their index numbers

Use enumerate() when each item should be accompanied by its position:

for index, color in enumerate(colors):
    print(index, color)

By default, the first index is 0. To number the first item as 1, pass a starting value:

for number, color in enumerate(colors, start=1):
    print(number, color)

enumerate() provides the index and corresponding value together, as described in the Python data-structures tutorial.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Print a list without brackets

Use argument unpacking with a separator to show the elements on one line:

print(*colors, sep=', ')

Output:

red, green, blue

The * expands the list into separate arguments, and sep specifies the text printed between those arguments. It does not change the list. If the list is empty, this call prints a blank line. This form is convenient for simple output; use a loop when you need to transform or specially format individual elements.

Format nested or long lists

For nested lists or structures that are difficult to scan on one line, use Python’s pprint module:

import pprint

pprint.pp([[1, 2], [3, 4]])

pprint.pp() keeps a structure on one line when it fits and introduces line breaks when it exceeds the configured width. Use pprint.pprint() when you want to specify options such as width or indentation. The pprint documentation describes its formatting behavior and options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why typing the list name may not print it

In an interactive Python session, entering a variable name by itself displays its representation. In a script, use print(items) when you want the list written to the program’s output.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Avoid confusing list output with list modification

A list method that changes the list is not necessarily a printing operation. For example, items.sort() sorts the list in place and returns None; printing that method call’s return value will show None, not the sorted list. Sort first, then print the variable:

items.sort()
print(items)

Python’s data-structures tutorial explains that mutating list methods such as sort() return None. Also, a set is not a list: sets are unordered, so their displayed order should not be treated as stable list ordering.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.