Remove Brackets and Commas from a List in Python

Today we are going to cover the best and most easy methods which will help you to remove brackets and commas from a list in a python program so let’s start.

If you don’t know about List in Python so See This.

There are some best ways to remove brackets and commas from a list in python.

1) For Loop

For loop comes first in mind when we have to do these types of tasks, let’s try it.


for f in fruits:
 print(f , end = " ")
 print(" ")

In the above code, we Iterate each value of the list through for loop and then print the values, using for loop in such a way that will remove the brackets, quotations, and Commas.



* Operator with Sep Method


fruits=["apple", "banana", "orange", "mango"]

print(*fruits, sep=" ")

In the above code, we utilize * which will remove all the brackets and commas, and quotations from the list, you can separate them by adding the sep keyword as you can see in the example.


apple banana orange mango

Translate Method()

The translate method is a string method that will change the strings by replacing or deleting the characters. Let’s have an example.


fruits = ["Apple","banana","orange","mango"] 

rep = {39: None, 91: None , 93: None} 


In the above example after declaring the list we mention the changes which we want in our string to the target variable, 39, 91, and 93 are the ASCII codes for quotations and brackets, we set these characters to none and translate our list by converting it into a string because translate is a string method. the desired output is below:



As you can see from the result above there are no brackets and quotations in the list.


So today we cover some interesting examples and methods which will help to remove brackets and commas from a list in python.

Suggested Articles:

Leave a Comment