list to string
jay graves
jgraves3 at austin.rr.com
Mon Feb 26 21:50:38 EST 2001
On Tue, 27 Feb 2001 02:42:12 GMT, glen mettler <glen.mettler at home.com>
wrote:
>These commands will turn a string into a list:
>myword="dog"
>mywordlist=list(myword)
>result = ["d","o","g"]
>
>is there a command/function that can take the list ["d","o","g"] and make it a string "dog"?
One way is to join them.
''.join(result)
Some people don't like using the string methods in this way and they
might write: (at least until the string module goes away.)
import string
string.join(result,'')
Hope this helps.
...
jay
More information about the Python-list
mailing list