Producing multiple items in a list comprehension

Joel Koltner zapwireDASHgroups at yahoo.com
Thu May 22 16:39:28 EDT 2008


"Peter Otten" <__peter__ at web.de> wrote in message 
news:g14gkp$gs2$01$1 at news.t-online.com...
>> A slightly similar problem: If I want to "merge," say, list1=[1,2,3] ...
>>>> items = [None] * 6
>>>> items[::2] = 1,2,3
>>>> items[1::2] = 4,5,6
>>>> items
> [1, 4, 2, 5, 3, 6]

Thanks Peter, that's pretty clean -- I like it!





More information about the Python-list mailing list