newbie - concatanating 2 lists
Michael Hudson
mwh21 at cam.ac.uk
Wed Feb 21 12:40:41 EST 2001
"Gnanasekaran Thoppae" <gnana at mips.biochem.mpg.de> writes:
> hi,
>
> i am just beginning to use python.
>
> i have:
>
> li1 = ['a', 'b', 'c']
> li2 = ['x', 'y', 'z']
>
> i want:
>
> li3 = ['ax', 'by', 'cz']
>
> how do i do it?
map(lambda x,y: x+y, li1, li2) will do.
More generally,
map(''.join, zip(li1, li2))
will extend to >2 lists.
Cheers,
M.
--
But since I'm not trying to impress anybody in The Software Big
Top, I'd rather walk the wire using a big pole, a safety harness,
a net, and with the wire not more than 3 feet off the ground.
-- Grant Griffin, comp.lang.python
More information about the Python-list
mailing list