list to string
Jeremy Hylton
jeremy at alum.mit.edu
Mon Feb 26 21:58:58 EST 2001
>>>>> "gm" == glen mettler <glen.mettler at home.com> writes:
gm> These commands will turn a string into a list:
gm> myword="dog"
gm> mywordlist=list(myword)
gm> result = ["d","o","g"]
gm> is there a command/function that can take the list ["d","o","g"]
gm> and make it a string "dog"?
string = "".join(result)
That is, call the join method of the empty string, passing it result
as an argument.
or
>>> "!".join(result)
'd!o!g'
Jeremy
More information about the Python-list
mailing list