How to Print a List Without Brackets in Python?

Recently, in a Python webinar, someone asked me how to print a list without brackets in Python. Then, I researched more about this topic and found six effective methods to accomplish this task. In this tutorial, I will explain all the important methods along with suitable examples, which will help you to understand better.

Print a List Without Brackets in Python

To print a list without brackets in Python, use the join() method. For example, if you have a list names = ["John", "Emily", "Michael"], you can print it without brackets by using print(", ".join(names)) , which will output: John, Emily, Michael.

Let’s get into the various methods you can use to achieve this, complete with examples featuring USA-specific names to make the tutorial relatable for our audience.

Read How to Generate a List of Random Numbers in Python?

Method 1: Use the Asterisk (*) Operator

One of the simplest ways to print a Python list without brackets is by using the unpacking operator *. This operator unpacks the elements of the list, allowing you to print them directly.

Example

names = ["John", "Emily", "Michael", "Sarah"]
print(*names)

Output:

John Emily Michael Sarah

You can see the output in the screenshot below.

Print a List Without Brackets in Python

Explanation

In the example above, the *names syntax tells Python to unpack the list names and pass each element as a separate argument to the print() function. By default, print() separates arguments with a space, resulting in a clean output.

Check out How to Get the Index of an Element in a List in Python?

Method 2: Use the sep Parameter

The print() function in Python includes a sep parameter that allows you to specify a custom separator between the elements. This method is particularly useful if you want to use a different separator, such as a comma or a hyphen.

Example

names = ["John", "Emily", "Michael", "Sarah"]
print(*names, sep=", ")

Output:

John, Emily, Michael, Sarah

You can see the output in the screenshot below.

How to Print a List Without Brackets in Python

Explanation

Here, we used sep=", " to specify that a comma followed by a space should separate the elements. This is a great way to format lists for better readability, especially when presenting data in a structured format.

Read How to Merge Lists Without Duplicates in Python?

Method 3: Join the List Elements

Another effective way to print a list without brackets is to use the join() method in Python. This method is particularly useful when you want to convert the list elements into a single string with a specified separator.

Example

names = ["John", "Emily", "Michael", "Sarah"]
output = " ".join(names)
print(output)

Output:

John Emily Michael Sarah

You can see the output in the screenshot below.

Print a List Without Brackets in Python Join the List Elements

Explanation

In this example, " ".join(names) concatenates the list elements into a single string, with a space as the separator. This approach is flexible and allows for any separator you choose, making it ideal for various formatting needs.

Check out How to Convert String to List in Python?

Method 4: Use a Loop

If you prefer a more manual approach, you can use a loop to iterate through the Python list and print each element. This method gives you complete control over how each element is printed.

Example

names = ["John", "Emily", "Michael", "Sarah"]
for name in names:
    print(name, end=" ")

Output:

John Emily Michael Sarah 

Explanation

In this code, the end=" " parameter in the print() function prevents the default newline character from being added after each print statement. Instead, it adds a space, resulting in a single line of output.

Read Convert String to List in Python Without Using Split

Method 5: List Comprehension with join()

For those who enjoy concise code, you can combine list comprehension with the join() method. This is particularly useful if you want to format the Python list elements in a specific way before printing.

Example

names = ["John", "Emily", "Michael", "Sarah"]
output = " | ".join([name.upper() for name in names])
print(output)

Output:

JOHN | EMILY | MICHAEL | SARAH

Explanation

In this example, we used a list comprehension to convert each name to uppercase before joining them with " | " as the separator. This method is powerful for applying any transformation to the list elements while printing them.

Check out How to Iterate Through a List in Python?

Method 6: Use format() for Custom Output

If you need even more control over how your Python list is printed, you can use the format() method. This allows you to create custom output formats.

Example

names = ["John", "Emily", "Michael", "Sarah"]
formatted_output = "Names: {}".format(" ".join(names))
print(formatted_output)

Output:

Names: John Emily Michael Sarah

Explanation

In this case, we created a string that includes the list of names, formatted to include a label. This approach is useful for creating more informative output.

Read How to Write a List to a File in Python?

Conclusion

In this article, I helped you learn how to print a list without brackets in Python. I discussed six methods, such as using the asterisk(*) operator, using the sep parameter, join the list elements using a loop, list comprehension with join(), and use format() for custom output.

You can read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.