How to convert a list to a string

Possible duplicate:

How to convert a list to a string?

How to convert a list to a string using Python?

+397
source share
3 answers

Using ''.join

list1 = ['1', '2', '3']
str1 = ''.join(list1)

Or, if a list of integers, convert the elements before joining them.

list1 = [1, 2, 3]
str1 = ''.join(str(e) for e in list1)
+724
source
>>> L = [1,2,3]       
>>> " ".join(str(x) for x in L)
'1 2 3'
+128
source
L = ['L','O','L']
makeitastring = ''.join(map(str, L))
+48
source

All Articles