[Tutor] string to list of characters

Rick Pasotto rick@niof.net
Tue, 7 Aug 2001 23:49:26 -0400


On Wed, Aug 08, 2001 at 04:29:22AM +0100, 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?

>>> w = 'dog'
>>> l = list(w)
>>> print w
dog
>>> print l
['d', 'o', 'g']

-- 
We must cease believing in anything in this world, in facts, in
justice, in universal consent, in human language; or else we must
admit that these two words, "property" and "plunder", express
opposite, irreconcilable ideas that can no more be identified than
yes and no, light and dark, good and evil, harmony and discord.
Taken literally, the famous formula, property is theft, is
therefore absurdity raised to the nth degree. It would be no less
outlandish to say that theft is property; that what is legal is
illegal; that what is, in not, etc.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net