Converting a List into a String

B

blah

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?
 
W

Will McGugan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Forum statistics

Threads
474,270
Messages
2,571,341
Members
48,029
Latest member
Anchorman2022

Latest Threads

Top