How to print array list without brackets in python

+1 vote

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 19, 2018 in Python by ned_crew
• 1,610 points
143,905 views

12 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 19, 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
Hello @Orestarod! I hope you are doing good. Register at Edureka Community and earn credits for every contribution(asking, answering, commenting or even upvoting or downvoting) you make.
you cant use join function with iterables . It works only with strings
Thank you very much!
+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
This is not working for me.I want to separate a single column from a dataframe and print the output as an array.Need help.Thanks
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 9, 2019 by Praveen Daniel
0 votes
for x in like:

print (x)
answered Feb 27, 2019 by Suresh
0 votes

print list without bracket

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

output:

Rajesh,Raj,Amit,Neha,Annu

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

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

Gwynfryn

Can you tell what is * for ?

Hey,

If you want to print the elements of the list or array without using loops, then you can use the '*' symbol to print the list elements in a single line with space.

Why i can't? In the terminal there syntaxError . The error because the *

Hey, @There,

Could you please post all your error logs? Please post your workaround.

0 votes
try this :

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

print(''.join(alphabet))
answered Apr 15, 2019 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, 2019 by anonymous
0 votes

Call print(*value, sep=" ") with value as a list to unpack and print the elements of the list seperated by the zero or many characters contained in sep. To seperate each element with a comma followed by a space, set sep to ", ".

a_list = ["a", "b", "c"]
print(*a_list, sep = ", ")

OUTPUT

a, b, c
answered Dec 10, 2020 by anonymous
• 82,840 points

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 5, 2018 in Python by Omkar
• 69,220 points

edited Aug 8, 2018 by Omkar 8,150 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
1,067 views
0 votes
1 answer
+4 votes
7 answers
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
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
1,265 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, 2019 in Python by anonymous
5,858 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP