Convert List of Characters to String
Given a list of characters chars, we need to join these characters into a string.
To convert a given list of characters into a string in Python, we can use String.join() method. The join() method takes an iterable as argument, and joins the items in the iterable with the calling string as separator string.
Since we need to just join the chars to form a string, we take an empty string as separator string.
The syntax of the expression to join the items in list of characters chars using String.join() method is
The above expression returns a string formed by joining the items of the given list chars.
In the following program, we take a list of characters in chars and join them into a string.
Run Code Copy
myList = ['a', 'p', 'p', 'l', 'e'] output = ''.join(myList) print(output)
In this tutorial of Python Examples, we learned how to join the items in given list of characters into a string using String.join() method, with the help of well detailed examples.