The easiest way is to simply use list() , but there is at least one more option:
s = "Word to Split" wordlist = list(s) # option 1, wordlist = [ch for ch in s] # option 2, list comprehension.
They should give you what you need:
['W','o','r','d',' ','t','o',' ','S','p','l','i','t']
As indicated, the first is most likely the most preferable for your example, but there are use cases that can make the latter very convenient for more complex things, for example, if you want to apply some arbitrary function to the elements, for example, using
[doSomethingWith(ch) for ch in s]
paxdiablo Sep 22 '08 at 7:46 2008-09-22 07:46
source share