W3docs

How to convert list to string

You can use the join() method to convert a list of strings to a single string.

You can use the join() method to convert a list of strings to a single string. The join() method takes one parameter, which is the delimiter that separates the elements of the list in the resulting string. Here's an example:

Join a list's elements to create a string in Python

list_of_strings = ["Hello", "world"]
result_string = " ".join(list_of_strings)
print(result_string) # "Hello world"

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Python - The Practical Guide</div>

In this example, the delimiter is a space character, so the resulting string will have a space between the words "Hello" and "world". You can use any delimiter you want, including an empty string to join the list elements without any delimiter.