This post will discuss how to convert a string to a list of characters in Python.

Although Python allows you to access individual characters of a string using index operator [] and also allows you to iterate over a string easily but depending upon your use case, you might want to create a list from characters of a string. This can be achieved either using the list constructor or the list comprehension.

1. Using list() constructor

The list() constructor builds a list directly from an iterable, and since the string is iterable, you can construct a list from it. Performing list(s) on a string s returns a list of all the characters present in the string, in the same order as the string’s characters. So, all you need to do is pass your string object to the list constructor, as shown below:

Download  Run Code

2. Using List Comprehension

Another approach is to use list comprehension. List comprehension is often used in Python to construct a new list, where each list element results from some operation applied to each member of an iterable. This can be implemented as:

Download  Run Code

3. Using str.split() function

If you need to split your string based on a delimiter and construct a list out of items, you can use the str.split() function:

Download  Run Code

That’s all about converting a string to a list of characters in Python.