list to string python

47

list1 = [1, 2, 3]
str1 = ''.join(str(e) for e in list1)
list1 = ['1', '2', '3']
str1 = ''.join(list1)
>>> L = [1,2,3]       
>>> " ".join(str(x) for x in L)
'1 2 3'
>>> words = ["Messi", "is", "the", "best", "soccer", "player"]
>>> sentence = " ".join(words)
>>> sentence
'Messi is the best soccer player'

Comments

Submit
0 Comments