How to print array/ list without brackets in python?

+2 votes

I want to print a list in python without the square brackets. It is always coming printing like [“a”,”b”,”c”]

Announcement! Career Guide 2019 is out now. Explore careers to become an AI/ ML Engineer or Data Scientist!

Apr 18, 2018 in Python by ned_crew
• 1,620 points
22,655 views

11 answers to this question.

+2 votes
name=["a","b","c"]
print (', '.join(name))

It will simply take all the elements in a list(name), and joins them with ‘, ’

answered Apr 18, 2018 by aayushi
• 750 points
a=[1,2,3,4,5]

print(*a, sep =' ')

o/p : 1 2 3 4 5
Hey @santosh. Why cant I use print (', '.join(a)) for a=[1,2,3,4,5]

I am getting error:

TypeError: sequence item 0: expected str instance, int found

Because join() is a method of a string type object, and joins lists that are made of string type objects. If your list is consisted of integers, it would not work. For example, you would have to do str() on all elements of your list to do a join() on it.

hey friends how to function return type a list with braces and coma's
+1 vote
print (','.join(name_of_list))
answered Dec 10, 2018 by Karunes
+1 vote

You can try this for arrays:

print str(names)[1:-1]
answered Dec 10, 2018 by George
+2 votes
print(*names, sep = ', ')

This is what I use

answered Dec 10, 2018 by Sudo
Thank you, this worked for me!

-Catherine
0 votes

You can use looping to do this. This is not the best way but it is a possible way so I posted it:

for name in names:
        print(names[index], end=", ")
        index += 1
answered Dec 10, 2018 by Chandu
+1 vote
print(", ".join(str(x) for x in name))
answered Dec 10, 2018 by Lagu
0 votes
print(",".join(["a","b","c"]))
answered Feb 8 by Praveen Daniel
0 votes
for x in like:

print (x)
answered Feb 27 by Suresh
0 votes

print list without bracket

list = ["Rajesh", "Raj", "Amit", "Neha", "Annu"]
print(*list, sep=", ")

output:

Rajesh,Raj,Amit,Neha,Annu

  if you are interested to learn more about python like list ,tuplple ,dictionary,set etc. than i would like to suggest you can  join best industrial training in python

answered Apr 9 by rajesh
• 1,210 points
thank u so much
Hello rajesh,

Thank you for the best answer ever I've found anywhere.

Gwynfryn
0 votes
try this :

alphabet=['a','b','c']

print(''.join(alphabet))
answered Apr 15 by Alireza Bahrami
please tell me how to read and print array of n elements in python

You can read array from the users like this:

array=list(map(int,input().split()))

And you can directly print the array as follows:

print(array)

There are many other ways to read and write an array. Do you want any particular way to do this?

0 votes
name=["a","b","c"]
print (', '.join(name))
answered May 6 by anonymous

Related Questions In Python

+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 67,480 points

edited Aug 8, 2018 by Omkar 651 views
0 votes
1 answer

How to Print a List in Python

ou are using Python 2.x syntax with ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
77 views
+4 votes
7 answers
0 votes
1 answer

How to print first character of each word in upper case of a string in Python

You can use split() using space as ...READ MORE

answered Jun 1, 2018 in Python by george
• 200 points
1,808 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 229 views
0 votes
1 answer

How to add a new line in Python?

You can use '\n' for a next ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
90 views
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2 in Python by anonymous
186 views