Convert String to a List of Characters

To convert a given string into a list of characters, we can use list() builtin function. list() builtin function when provided with an iterable, creates a list with the elements of the iterable. Since, string is an iterable of characters, when we pass string as an argument to list() function, it returns a list created from the characters of the given string.

The syntax of the expression to create a list of characters from the string myString is

</>
Copy
list(myString)

Program

In the following program, we take a string name, and convert this string to a list of characters using list() builtin function.

main.py

</>
Copy
name = "apple"
chars = list(name)
print(chars)

Output

['a', 'p', 'p', 'l', 'e']

References

Conclusion

In this Python Tutorial, we learned how to convert a given string into a list of characters.