[Tutor] list concatenation

Bob Gailer ramrom@earthling.net
Wed Feb 5 13:39:02 2003


--=======DFB19B1=======
Content-Type: text/plain; x-avg-checked=avg-ok-66062ABC; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 07:37 AM 2/5/2003 -0800, Lance wrote:
>What's the fastest way to concatenate the same string to all elements of a 
>list?

List comprehension provides the least code way to do this:

list = ['name1', 'name2', 'name3']
path = 'c:\\folder\\'
full_list = [path + fn for fn in list]

Bob Gailer
mailto:ramrom@earthling.net
303 442 2625

--=======DFB19B1=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-66062ABC
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.445 / Virus Database: 250 - Release Date: 1/21/2003

--=======DFB19B1=======--