Python – How to split a string into a list of characters in Python

pythonsplit

I've tried to look around the web for answers to splitting a string into a list of characters but I can't seem to find a simple method.

str.split(//) does not seem to work like Ruby does. Is there a simple way of doing this without looping?

Best Answer

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

You need list