• Register

How to print a list in python without the brackets

I have a list in Python e.g.

letters = ["t", "h", "e"]

I want to print the array in a single line without the normal " []
 

names = ["t", "h", "e"]
print (letters)

Will give the output as;

["t", "h", "e"]

That is not the format I want instead I want it to be like this;

t, h, e

Note: It must be in a single row.

>> arr = [1, 2, 4, 3]
>>> print(", " . join(arr))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected string, int found
>>> sarr = [str(a) for a in arr]
>>> print(", " . join(sarr))
1, 2, 4, 3
>>>

 

More Posts

How to print the index of a list python offonime - Jul 4
Print hello world in C without using Printf sakshi - Jul 3
How to find the index of an element in a list python Tania - Jul 12
How to find the index of an element in a list in python mhfaisal - Jun 5
How do you display hyperlinks without an underline Sanjana Sagar - May 22
How to append to the beginning of a list python Tania - May 12
How to print a range of numbers in python amna - Jul 3
How to print a function in python amna - Jun 29
How to print a string and a variable in python offonime - May 22
How to find the number of unique elements in list in Python mhfaisal - Jul 14