How to print array/ list without brackets in python?

510    Asked by Chandralekhadebbie in Python , Asked on Apr 12, 2021

I have a list in Python e.g.

names = ["A", "B", "C"]
I want to print the array in a single line without the normal " []
names = ["A", "B", "C"]
print (names)
Will give the output as:
["A", "B", "C"]
That is not the format I want instead I want it to be like this;
A, B, C


It is very simple to do a print list without brackets in python. You can simply use the python's join method on a string. Like this:

names = ["A", "B", "C"]
print(', '.join(names))
It will print:
A, B, C


Your Answer

Interviews

Parent Categories