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

+3 votes
Aug 4, 2018 in Python by Abhishek
• 240 points

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote
Best answer

Hey @abhijmr.143, you can print array integers in the format mentioned in your question with the following code:


from __future__ import print_function 
a = [1,2,3,4,5]
for value in a: 
    print(value, end=',') 
print(" ") 




from __future__ import print_function #This line is only needed in Python 2.X, you can skip this line if you are using python 3.X
a = [1,2,3,4,5] #array initialization
for value in a: #loop to print all array elements
    print(value, end=',') #This line prints the array integers with a comma(,) as its suffix and prints a comma even after the last integer
print("\b",end="") #This line is used to move the cursor to the last printed character
print(" ") #This line replaces the comma(,) printed after the last integer with a blank space
answered Aug 4, 2018 by Omkar
• 67,000 points

edited Aug 8, 2018 by Omkar
+1 vote

from __future__ import print_function

data = [7, 7, 7, 7]
print(*data, sep='')
answered Aug 6, 2018 by Sushmita
• 6,840 points
This code will print the output as follows:

To print the data as mentioned in the question, edit the last line of your code as follows:
print(*data, sep=',')

Related Questions In Python

+2 votes
11 answers

How to print array/ list without brackets in python?

name=["a","b","c"] print (', '.join(name)) It will simply take all ...READ MORE

answered Apr 18, 2018 in Python by aayushi
• 750 points
+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
0 votes
1 answer

How to use string.replace() in python 3.x

replace() is a method of <class 'str'> ...READ MORE

answered Aug 3, 2018 in Python by Priyaj
• 56,140 points
+1 vote
1 answer

How to print an error in Python?

For Python 2.6 and later and Python ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 56,140 points
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,710 points
0 votes
1 answer

How to save Numpy array as image in python?

If you have matplotlib, you can do: import ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,500 points
0 votes
1 answer

How to add integer to python array?

You have defined a numpy array but ...READ MORE

answered Feb 3 in Python by Omkar
• 67,000 points
0 votes
1 answer

How to check latest change time of each file using glob in python?

You can get the changing time from ...READ MORE

answered Jan 2 in Python by Omkar
• 67,000 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.