Converting a List into a String

Will McGugan news at NOwillmcguganSPAM.com
Sat Nov 5 05:49:53 EST 2005


blah at blah.blah wrote:
> I have a List
> 
> list = ['f', 'e', 'd', 'c', 'b', 'a']
> 
> How can i convert it into a string so the output is
> 
> fedcba
> 
> i used
> 
> for a in list:
>       print a,
> 
> the output is 
> 
> f e d c b a
> 
> How can i remove the spaces b/w each letter?

print "".join(list)

BTW list isnt a good name for a list, it hides the built in type.


Will McGugan
-- 
http://www.willmcgugan.com
"".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
"jvyy*jvyyzpthtna^pbz")



More information about the Python-list mailing list