Use print(items) to display a list with its brackets and normal Python representation. To show one item per line, loop over the list; use enumerate() for numbered output, print(*items, sep=', ') for a separator without brackets, or pprint.pp() for nested data.
Print a whole list with its brackets
Pass the list to print() to show its normal representation:
As an Amazon Associate I earn from qualifying purchases.
colors = ['red', 'green', 'blue']
print(colors)
Output:
['red', 'green', 'blue']
The square brackets and quotes around strings are part of how Python represents the list; they do not mean those characters are stored as list elements. For ordinary built-in lists, str() and repr() often produce the same-looking display, though they have different aims: str() is intended to be fairly human-readable, while repr() is intended to be readable by the interpreter when possible. See the Python tutorial’s input and output documentation.
Print each item on a new line
Iterate over the list and print each value separately:
#1 Best Overall
for color in colors:
print(color)
Each call to print() ends with a newline by default, so the values appear on separate lines. This also works for an empty list: the loop runs zero times and prints nothing.
Print a list without brackets
Use argument unpacking with a custom separator when you want one line of values without the list’s brackets:
Rank #2
print(*colors, sep=', ')
Output:
red, green, blue
The * passes the list elements as separate arguments to print(), and sep controls the text between those arguments. It does not change the list. If the list is empty, this call prints a blank line. The sep parameter separates arguments, not characters within a single string.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Print values with their positions
Use enumerate() when each item should be paired with its index:
for index, color in enumerate(colors):
print(index, color)
By default, the index starts at zero. To number the output starting at one, provide a starting value:
for number, color in enumerate(colors, start=1):
print(number, color)
Python’s tutorial documents enumerate() as a way to retrieve a sequence position and value together; see Data Structures.
Format nested or long lists
For nested data, pprint.pp() displays a readable representation and adds line breaks when the structure exceeds its configured width:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11import pprint
pprint.pp([[1, 2], [3, 4]])
Use pprint.pprint() if you want to set options such as width or indentation explicitly. The Python 3.11.16 pprint documentation describes the module’s formatting behavior and options.
Quick Recap
Best Value
Common mistakes to avoid
- Relying on a bare variable name in a script: entering
colorsby itself displays a value in an interactive session, but a script should callprint(colors)when output is intended. - Expecting a different display from a list method: methods that mutate a list, such as
colors.sort(), change the list and returnNone; they are not a way to print the changed list. Callprint(colors)separately if you want to display it. - Assuming a set has list ordering: sets are unordered, unlike lists, so do not rely on a set’s display to preserve a sequence order.
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.




