Splice two lists
Michael J. Fromberger
Michael.J.Fromberger at Clothing.Dartmouth.EDU
Sat May 6 21:10:51 EDT 2006
In article <1146961724.195038.18680 at u72g2000cwu.googlegroups.com>,
"danmcleran at yahoo.com" <danmcleran at yahoo.com> wrote:
> Is there a good way to splice two lists together without resorting to a
> manual loop? Say I had 2 lists:
>
> l1 = [a,b,c]
> l2 = [1,2,3]
>
> And I want a list:
>
> [a,1,b,2,c,3] as the result.
>
> I've been searching around but I can't seem to find a good example.
Here's one possibility:
list(reduce(lambda s, t: s + t, zip(L1, L2), ()))
-M
--
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA
More information about the Python-list
mailing list