Converting a list to a string

Fredrik Lundh fredrik at effbot.org
Tue Dec 19 20:55:46 CET 2000


Daniel Klein wrote:
> My application needs to be able to convert a list to a string and vice
> versa. Taking the first problem, the best I could come up with is

I assume "list" means list of strings:

    s = string.join(mylist, "")

(or in 1.6 and later, s = "".join(mylist))

not sure what "vice versa" means, but maybe string.split
(or the split method) is what you need?

check the string module docs for details (it's in the library
reference).

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list