[Tutor] string to list of characters
Tue, 7 Aug 2001 22:26:15 -0700 (PDT)
On Wed, 8 Aug 2001, sean dowie wrote:
> I want to turn a word into a list of the letters, eg "dog" becomes
> ['d', 'o', 'g']. Is there a simple way to use split() or something to
> do this, or do I have to loop through each letter of the string?
By the way, you can treat a string as a "sequence" of characters:
>>> kujo = 'dog'
>>> for letter in kujo:
... print letter
and many of the operations that work with lists can work equally well with
strings. So, depending on the task, you might not need to turn "dog" into
['d', 'o', 'g'].