You can use join with list comprehension:

>>> l=range(5)
>>> print l
[0, 1, 2, 3, 4]
>>> ''.join(str(i) for i in l)
'01234'

Also, don't use list as a variable name since it is a built-in function.

Answer from fredtantini on Stack Overflow
๐ŸŒ
Quora
quora.com โ€บ How-do-you-print-a-list-without-spaces-in-Python
How to print a list without spaces in Python - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
Discussions

python - Print list without spaces - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I have this code here. I want to print a list without spaces. More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to convert list to string without brackets or spaces?

join method of strings.

','.join(test)

Although, since you've got integers in that list, you'll have to convert them to strings.

','.join(str(num) for num in test)
More on reddit.com
๐ŸŒ r/learnpython
3
1
May 3, 2017
Printing Values from a list without spaces in python 2.7 - Stack Overflow
Suppose I have a list like list1 = ['A','B','1','2'] When i print it out I want the output as AB12 And not A B 1 2 So far I have tried (a)print list1, (b)for i in list1: print i, (c)for ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
November 2, 2016
Printing list as string without brackets or commas
You can use the very convenient join() function for that: ','.join(strPorG) More on reddit.com
๐ŸŒ r/learnpython
5
2
September 27, 2021
๐ŸŒ
Codingem
codingem.com โ€บ home โ€บ python how to print without spaces (examples)
Python How to Print Without Spaces (Examples) - codingem.com
December 5, 2022 - To print without a space in Python, you can set the sep parameter to specify a separator between the values you are printing. For example, to print a list of numbers without any spaces between them, you could use the following code:
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-print-list-without-spaces
Python - Print list without spaces
To print list without spaces in Python, write a custom function that takes a list as argument, joins all the elements in the list with just a comma character as separator between the elements, and enclose the resulting string in square brackets.
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ python print without space
Python Print Without Space - Be on the Right Side of Change
September 21, 2022 - To print multiple values or variables without the default single space character in between, use the print() function with the optional separator keyword argument sep and set it to the empty string ''. For example, the statement print('hello', 'world', sep='') prints helloworld without the ...
๐ŸŒ
Quora
clcoding.quora.com โ€บ How-to-print-a-list-without-spaces-in-Python
How to print a list without spaces in Python - Python Coding - Quora
Answer: YourList = โ€œโ€.join(list object) will get you the list elements without spaces. Then Print(YourList) will print it.
Find elsewhere
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to convert list to string without brackets or spaces?
r/learnpython on Reddit: How to convert list to string without brackets or spaces?
May 3, 2017 -

This seems like it has a simple solution but I can't seem to find it. I have a list

test = [1, 2, 3, 4]

and I want to convert it to the string and remove the brackets and spaces

1,2,3,4

I've found that I can print the list correctly by using

print(*test, sep=',')

but I want to concatenate the string for use elsewhere, not just print it.

Any ideas?

๐ŸŒ
Finxter
blog.finxter.com โ€บ how-to-print-a-list-without-brackets-and-commas-in-python
How to Print a List Without Brackets and Commas in Python? โ€“ Be on the Right Side of Change
For example, the expression print(*my_list) prints the elements in my_list, empty space separated, without the enclosing square brackets and without the separating commas!
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ python print without space
How to Print Values Without Spaces in Between in Python | Delft Stack
February 2, 2024 - The sep parameter can only be found and used in Python 3 and later versions. It can also be utilized for the formatting of the output strings. The following code uses the sep parameter to print without spaces between values in Python.
๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ python โ€บ print without space in python
Print Without Space in Python [4 Ways] - Java2Blog
March 7, 2023 - Use + operator to print without space in Python. ... Here, we used the string concatenation operator represented with the + sign, used to concatenate the strings without any separator, but it would be challenging to use if we have many string ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-print-a-list-without-brackets-in-python
How to Print a List Without Brackets in Python - GeeksforGeeks
July 23, 2025 - The most simple and efficient method is using * operator to unpack the list elements when passing them to the print function. It prints the list elements separated by spaces without the need for additional formatting.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ printing list as string without brackets or commas
r/learnpython on Reddit: Printing list as string without brackets or commas
September 27, 2021 -

I'm working on a homework assignment for my online class and got it finished down to this:

I'm having an issue finding out how to get the string to fulfill the necessary tasks and still print in the way desired below.

Write code that does the following:

  1. Compute the number of words in variable sentence that contain either an "p" or an "g". Store the result in the variable numPorG.

  2. Creates a string strPorG composed of those words in sentence that contain an "p" or "g". Each word in strPorG must be separated by a comma.

Print the variables numPorG and strPorG as shown below.

Do not double-count words that contain both an p and an g. Use the in operator to test for existence.

sentence = "python is a high level general purpose programming language that can be applied to many different classes of problems"

##### My code below:

sentence = sentence.split()
numPorG = 0
strPorG = []

for word in sentence:
if 'p' in word or 'g' in word:
numPorG += 1
strPorG.append(str(word))

strPorG = str(strPorG) # I think this part is redundant

print("Number of words containing p or g is", numPorG)
print("Those words are", strPorG)

#####

Output I'm getting:
Number of words containing p or g is 8
Those words are ['python', 'high', 'general', 'purpose', 'programming', 'language', 'applied', 'problems']

Expected output:
Number of words containing p or g is 8
Those words are python,high,general,purpose,programming,language,applied,problems

๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ how to print a list without commas in python
How to Print a List Without Commas in Python - Be on the Right Side of Change
October 7, 2022 - For example, the expression print('[', *lst, ']') prints the elements in my_list, empty space separated, with the enclosing square brackets and without the separating commas!
๐ŸŒ
PythonHow
pythonhow.com โ€บ how โ€บ print-without-a-newline-or-space-in-python
Here is how to print without a newline or space in Python
# Print without a space print('Hello', end='') print('World', end='') ... You can also use the sep parameter of the print() function to specify a different separator between the items to be printed. This parameter specifies the string that should be used to separate the items, instead of the ...
๐ŸŒ
Docodehere
docodehere.com โ€บ home โ€บ python example
Print the list of integers from through as a string, without spaces. - Docodehere
May 16, 2021 - Without using any string methods, try to print the following: Note that "" represents the consecutive values in between. ... Print the string . ... The first line contains an integer . ... Print the list of integers from through as a string, without spaces.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ print-lists-in-python-4-different-ways
Print lists in Python - GeeksforGeeks
April 8, 2025 - If we want a more cleaner or customized output format then please follow the below discussed approach. We can use print(*list_name) when we want a simple and clean display of list elements without additional formatting like brackets or commas.
Top answer
1 of 4
156

You can apply the list as separate arguments:

print(*L)

and let print() take care of converting each element to a string. You can, as always, control the separator by setting the sep keyword argument:

>>> L = [1, 2, 3, 4, 5]
>>> print(*L)
1 2 3 4 5
>>> print(*L, sep=', ')
1, 2, 3, 4, 5
>>> print(*L, sep=' -> ')
1 -> 2 -> 3 -> 4 -> 5

Unless you need the joined string for something else, this is the easiest method. Otherwise, use str.join():

joined_string = ' '.join([str(v) for v in L])
print(joined_string)
# do other things with joined_string

Note that this requires manual conversion to strings for any non-string values in L!

2 of 4
10

Although the accepted answer is absolutely clear, I just wanted to check efficiency in terms of time.

The best way is to print joined string of numbers converted to strings.

print(" ".join(list(map(str,l))))

Note that I used map instead of loop. I wrote a little code of all 4 different ways to compare time:

import time as t

a, b = 10, 210000
l = list(range(a, b))
tic = t.time()
for i in l:
    print(i, end=" ")

print()
tac = t.time()
t1 = (tac - tic) * 1000
print(*l)
toe = t.time()
t2 = (toe - tac) * 1000
print(" ".join([str(i) for i in l]))
joe = t.time()
t3 = (joe - toe) * 1000
print(" ".join(list(map(str, l))))
toy = t.time()
t4 = (toy - joe) * 1000
print("Time",t1,t2,t3,t4)

Result:

Time 74344.76 71790.83 196.99 153.99

The output was quite surprising to me. Huge difference of time in cases of 'loop method' and 'joined-string method'.

Conclusion: Do not use loops for printing list if size is too large( in order of 10**5 or more).

๐ŸŒ
Quora
quora.com โ€บ How-do-I-print-without-spaces-in-python
How to print without spaces in python - Quora
Answer (1 of 14): There are a load of correct or working answers here, but they all seem to over-complicate it. I believe it is as simple as this: 1. You are just learning, so use Python 3. 2. Python 3 adds a linefeed to the end of print statements by default.