newbie - concatanating 2 lists
Steve Purcell
stephen_purcell at yahoo.com
Thu Feb 22 05:22:01 EST 2001
Alex Martelli wrote:
> Steve Purclel wrote:
> > >>> li3 = map(lambda a,b: a+b, ['a','b','c'], ['x','y','z'])
>
> It's not the shortest way in Python2 -- rather, I'd code it:
>
> li3 = [ a+b for a,b in zip(li1, li2) ]
Hang on, it *is* still the shortest way in Python 2:
li3 = [a+b for a,b in zip(li1,li2)]
li3 = map(lambda a,b:a+b,li1,li2)
Any excuse to put off using list comprehensions for a while... :-)
-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
More information about the Python-list
mailing list