How can I convert a list to a string using Python?
3 Answers
Use ''.join:
xs = ['1', '2', '3']
s = ''.join(xs)
If the list contains integers, convert the elements to string before joining them:
xs = [1, 2, 3]
s = ''.join(str(x) for x in xs)
>>> xs = [1, 2, 3]
>>> " ".join(str(x) for x in xs)
'1 2 3'
xs = ['L', 'O', 'L']
lol_string = ''.join(map(str, xs))