faqts : Computers : Programming : Languages : Python : Common Problems : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

16 of 17 people (94%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Is it possible to convert a string to a list, using each character as a new list item?

Feb 6th, 2006 20:10
mazha lee, Jared Cerbin,


Yea, and it's simple
>>> str = 'hello python'
>>> list( str )
['h', 'e', 'l', 'l', 'o', ' ', 'p', 'y', 't', 'h', 'o', 'n']