python parsing question from a python newbie (though coding for 10 years)
Anton Muhin
antonmuhin at sendmail.ru
Mon Feb 3 13:39:52 EST 2003
Pat McGroin wrote:
> I need to take a string and parse\split\breakup the string into each
> seperate character into an array. The only part I don't know is how
> to split into seperate chars, could someone please give me a quick 1
> line of code answer?
>
> Thanks.
There are several ways. If you want simple lists, try this:
s = "abc"
list(s) --> ['a', 'b', 'c']
or
tuple(s) --> ('a', 'b', 'c')
If you want to iterate through chars:
for c in s:
print c
a
b
c
HTH,
Anton.
More information about the Python-list
mailing list