How to concatenate list members

holger krekel pyth at devel.trillke.net
Thu May 30 08:13:55 EDT 2002


Ruediger Maehl wrote:
> Hello Pythoneers,
> 
> I would like to concatenate all members of a list of strings.
> How can I do that?
> I know, I can use a for loop over all elements and concatenate
> them to one string. But is there another more efficient solution?

1) "sep".join(somelist)

   joins all objects in somelist (but the objects must of string-type!)

2) "sep".join(map(str, somelist))

   joins the string-representations of all objects in somelist

regards,

    holger





More information about the Python-list mailing list