Python - Create string from list of characters
Python - Create String from List of Characters
To create a string from a list of characters in Python, you can use string join() method.
Call join() method on an empty string, and pass the given list of characters as argument to the method.
For example, if my_list contains the list of characters, then the expression to create a string from this list of character is
"".join(my_list)
The above expression joins the characters in the given list with empty string as separator, and returns the resulting string.
1. Example to create a string from a list of characters using join() method in Python
In the following program, we take a list of characters in my_list, and create a string value from this list of characters.
Python Program
# Given list of characters
my_list = ["a", "p", "p", "l", "e"]
# Create string from lis of characters
result = "".join(my_list)
print(result)
Output
apple
Summary
In this tutorial of Python string operations, we learned how to create a string from a list of characters using string join() method, and understanding the practical application using an example.