[Pythonmac-SIG] dumping characters into a list

Sheila King sheila at thinkspot.net
Sat Jan 21 04:24:47 CET 2006


--On January 20, 2006 9:18:26 PM -0600 Silas Hundt <silashundt at gmail.com> 
wrote:

> Receive input, cut that string up into individual characters (ALL
> characters, including spaces), put them in order into a list, then
> pull them out in order to convert them to a number.
>
> So... should I go ahead and create a [freeking] translate() table, or
> does anybody else have some better creative answers?

Does this work for you?

Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "This is a string."
>>> list(s)
['T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 
'g', '.']
>>>

-- 
Sheila King
sheila at thinkspot.net
http://www.thinkspot.net/sheila/




More information about the Pythonmac-SIG mailing list