By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,444 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,444 IT Pros & Developers. It's quick & easy.

Converting a List into a String

P: n/a
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?
--
* Posted with NewsLeecher v3.0 Beta 7
* http://www.newsleecher.com/?usenet
Nov 5 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
''.join['h','i']

bl**@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?
--
* Posted with NewsLeecher v3.0 Beta 7
* http://www.newsleecher.com/?usenet


Nov 5 '05 #2

P: n/a
bl**@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")
Nov 5 '05 #3

P: n/a
bl**@blah.blah wrote:
list = ['f', 'e', 'd', 'c', 'b', 'a']

How can i convert it into a string so the output is

fedcba


print ''.join(list)
Nov 5 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.