Understanding How To Print List Without Brackets In Python

This tutorial is going to guide you through the process of printing a list without brackets in Python. It’s important to know how to print lists without brackets because it can be useful when trying t …

Updated November 30, 2023

This tutorial is going to guide you through the process of printing a list without brackets in Python. It’s important to know how to print lists without brackets because it can be useful when trying to manipulate or print the contents of lists.

Lists are one of the most common data types in Python, and they are used for several reasons including storing multiple items of the same type, performing operations on all items at once, etc. However, when you want to simply display the contents of a list without any extra characters, the brackets can get in the way. Here is how you can print a list with no brackets:

list_to_print = ['item1', 'item2', 'item3']
for item in list_to_print:
    print(item)

In this code, we are defining a list of strings. The for loop iterates over the list and prints each string on its own line. If you want to print all items in one line (without any brackets), use the join() method with no arguments:

list_to_print = ['item1', 'item2', 'item3']
print(' '.join(list_to_print))  # space between items
# OR
print(', '.join(list_to_print))  # comma between items

Both these lines of code print the list contents in a single line, separated by spaces or commas.

Stay up to date on the latest in Coding Python with AI and Data Science

Intuit Mailchimp