newbie - concatanating 2 lists

Gnanasekaran Thoppae gnana at mips.biochem.mpg.de
Wed Feb 21 12:48:43 EST 2001


Hi,

Thanks Steve and Perry.

I just realised that sometimes simple things can make one think a lot!
Python rocks!

-gnana

--- In python-list at y..., Steve Purcell <stephen_purcell at y...> wrote:
> Gnanasekaran Thoppae wrote:
> > i am just beginning to use python.
> 
> Good choice!
> 
> > li1 = ['a', 'b', 'c']
> > li2 = ['x', 'y', 'z']
> > 
> > i want:
> > 
> > li3 = ['ax', 'by', 'cz']
> 
> There may be more readable ways, but the shortest is probably this:
> 
> >>> li1 = ['a', 'b', 'c']
> >>> li2 = ['x', 'y', 'z']
> >>> li3 = map(lambda a,b: a+b, ['a','b','c'], ['x','y','z'])
> >>> li3
> ['ax', 'by', 'cz']
> 
> 
> -Steve
> 
> -- 
> Steve Purcell, Pythangelist
> Get testing at http://pyunit.sourceforge.net/
> Get servlets at http://pyserv.sourceforge.net/
> "Even snakes are afraid of snakes." -- Steven Wright
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list