Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Concatenating strings

Reply
Thread Tools

Concatenating strings

 
 
John Henry
Guest
Posts: n/a
 
      07-01-2006
Sorry if this is a dumb question.

I have a list of strings (some 10,000+) and I need to concatenate them
together into one very long string. The obvious method would be, for
example:

alist=["ab","cd","ef",.....,"zzz"]
blist = ""
for x in alist:
blist += x

But is there a cleaner and faster way of doing this?

Thanks,

 
Reply With Quote
 
 
 
 
Robert Kern
Guest
Posts: n/a
 
      07-01-2006
John Henry wrote:
> Sorry if this is a dumb question.
>
> I have a list of strings (some 10,000+) and I need to concatenate them
> together into one very long string. The obvious method would be, for
> example:
>
> alist=["ab","cd","ef",.....,"zzz"]
> blist = ""
> for x in alist:
> blist += x
>
> But is there a cleaner and faster way of doing this?


blist = ''.join(alist)

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
concatenating strings EHC Python 3 12-16-2006 12:07 AM
Help me with Concatenating strings c C Programming 21 10-15-2006 07:28 AM
Concatenating strings John Henry Python 1 07-01-2006 03:36 AM
adding strings, not concatenating them Stan Horwitz Perl 2 02-15-2006 08:38 PM
Problems concatenating strings stroker_ace@hotmail.com C++ 11 04-08-2005 03:32 PM



Advertisments