In this article, we would like to show you how to convert list to a string in Python.
my_list = ["a", "b", "c"] text = "".join(my_list) print(text) # abc
In this example, we convert list to a string using
join() method with a specified separator. This time as a separator we use a single space (
my_list = ["dirask", "is", "awesome"] text = " ".join(my_list) print(text) # dirask is awesome
dirask is awesome
We use a single space (
" ") as a separator in
join()method. To use a different separator, simply type new character in double-quotes before the metod.