How do I split a string into a list of characters? str.split does not work.

"foobar"    →    ['f', 'o', 'o', 'b', 'a', 'r']

14 s
14

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

Use the list constructor.

Leave a Reply

Your email address will not be published. Required fields are marked *