faqts : Computers : Programming : Languages : Python : Common Problems : Lists

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 13 people (100%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

I have a list of strings (or characters), how do I join it into one large string?

Jun 24th, 2002 06:25
Michael Chermside,


I have a list of strings (or characters), how do I join it into one
large string?
>>> aList = ['a','b','c','def']
>>> import string
>>> string.join( aList, '' )
'abcdef'
Or, if you can avoid doing the import by simply using the method of an
empty string:
>>> ''.join( aList )
'abcdef'