How do I split a string into a list of characters?

Use the list constructor:

>>> list("foobar")
['f', 'o', 'o', 'b', 'a', 'r']

list builds a new list using items obtained by iterating over the input iterable. A string is an iterable — iterating over it yields a single character at each iteration step.

Leave a Comment