Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

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

1 Answer

0 votes
by (25.1k points)
edited by

It is very simple to do that 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

Use this video to learn more about python:

Browse Categories

...