Skip to content

How to Print a List Without Brackets in Python

Learn how to remove square brackets and format Python lists as clean space-separated, comma-delimited, or custom-separated output using print(), join(), or string slicing.

When displaying list data to users: whether in console output, reports, log files, or user interfaces: Python's default list representation with square brackets and quotes is often undesirable. Instead of seeing [1, 2, 3, 4, 5], you typically want a cleaner format like 1 2 3 4 5 or 1, 2, 3, 4, 5.

In this guide, you'll learn multiple methods to print a list without brackets in Python, understand the differences between each approach, and choose the best one for your specific use case.

The simplest and most Pythonic way to print a list without brackets is using the * (unpacking) operator inside the print() function. It passes each list element as a separate argument to print():

li = [1, 2, 3, 4, 5]
print(*li)

Output:

1 2 3 4 5

By default, print() separates arguments with a space. You can customize the separator using the sep parameter:

li = [1, 2, 3, 4, 5]

print(*li, sep=', ')

print(*li, sep=' - ')

print(*li, sep='')

Output:

1, 2, 3, 4, 5
1 - 2 - 3 - 4 - 5
12345

Using the join() Method

The str.join() method concatenates list elements into a single string with a specified delimiter between them:

li = ['apple', 'banana', 'cherry']
print(', '.join(li))

Output:

apple, banana, cherry

You can use any delimiter:

li = ['apple', 'banana', 'cherry']

print(' | '.join(li))    # Pipe-separated
print(' -> '.join(li))   # Arrow-separated
print('\n'.join(li))     # Each element on a new line

Output:

apple | banana | cherry
apple -> banana -> cherry
apple
banana
cherry

Handling Non-String Elements

The join() method only works with strings. If your list contains integers or other types, you must convert them first:

li = [1, 2, 3, 4, 5]

try:
    print(', '.join(li))
except TypeError as e:
    print(f"Error: {e}")

Output:

Error: sequence item 0: expected str instance, int found

Fix: Use map() or a generator expression to convert elements to strings:

li = [1, 2, 3, 4, 5]

print(', '.join(map(str, li)))

print(', '.join(str(x) for x in li))

Output:

1, 2, 3, 4, 5
1, 2, 3, 4, 5

Using str() with String Slicing

A quick approach is to convert the list to its string representation and then slice off the brackets:

li = [1, 2, 3, 4, 5]
print(str(li)[1:-1])

Output:

1, 2, 3, 4, 5

This works because str([1, 2, 3, 4, 5]) produces the string '[1, 2, 3, 4, 5]', and [1:-1] removes the first character ([) and the last character (]).

Using a for Loop

A for loop gives you the most control over formatting. Use the end parameter in print() to keep elements on the same line:

li = [1, 2, 3, 4, 5]

for item in li:
    print(item, end=' ')

Output:

1 2 3 4 5 

Adding a Delimiter Between Elements (Not After the Last)

A common challenge with the loop approach is avoiding a trailing delimiter after the last element:

li = [1, 2, 3, 4, 5]

for item in li:
    print(item, end=', ')

Output:

1, 2, 3, 4, 5, 

Fix: Use enumerate() to detect the last element:

li = [1, 2, 3, 4, 5]

for i, item in enumerate(li):
    if i < len(li) - 1:
        print(item, end=', ')
    else:
        print(item)

Output:

1, 2, 3, 4, 5

Formatting Nested Lists Without Brackets

If you have a nested list (list of lists), you may want to remove brackets at multiple levels:

matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

for row in matrix:
    print(*row, sep='\t')

Output:

1	2	3
4	5	6
7	8	9

For a completely flat output:

matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

flat = [item for row in matrix for item in row]
print(*flat, sep=', ')

Output:

1, 2, 3, 4, 5, 6, 7, 8, 9

Comparison of Methods

Method Works with All Types Custom Delimiter Returns String Clean String Output
print(*li, sep=...) ✅ ✅ ❌ (prints only) ✅
', '.join(map(str, li)) ✅ (with map) ✅ ✅ ✅
str(li)[1:-1] ✅ ❌ (always , ) ✅ ❌ (keeps quotes on strings)
for loop with end ✅ ✅ ❌ (prints only) ✅

Summary

To print a list without brackets in Python:

  • Use print(*li) for the simplest, most Pythonic solution: customize spacing with the sep parameter.
  • Use ', '.join(map(str, li)) when you need a string result for storage, file writing, or further processing.
  • Use str(li)[1:-1] for a quick one-liner, but be aware it preserves quotes around string elements.
  • Use a for loop when you need maximum control over formatting, such as conditional delimiters or custom logic per element.

For most use cases, the * unpacking operator is the recommended approach due to its simplicity, readability, and compatibility with all data types.

Navigation