How to convert list to string

Created by Senthil KumaranLinked to 85.2m issues across 244 teams


To convert a list of integers to a string, use the following steps:

Step 1 - Use ''.join to create a list of integers, e.g.:

xs = [1, 2, 3] s = ''.join(xs)

Step 2 - If your list contains integers, convert each element of the list to a string before you join them, e.g. str(x)

xs = [1, 2, 3] s = ''.join(str(x) for x in xs)