A Faster Way...

Steven Bethard steven.bethard at gmail.com
Tue May 10 16:22:51 EDT 2005


andrea.gavana at agip.it wrote:
> If I simplify the problem, suppose I have 2 lists like:
> 
> a = range(10)
> b = range(20,30)
> 
> What I would like to have, is a "union" of the 2 list in a single tuple. In
> other words (Python words...):
> 
> c = (0, 20, 1, 21, 2, 22, 3, 23, 4, 24, 5, 25, .....

py> a = range(10)
py> b = range(20,30)
py> [x for tup in zip(a, b) for x in tup]
[0, 20, 1, 21, 2, 22, 3, 23, 4, 24, 5, 25, 6, 26, 7, 27, 8, 28, 9, 29]

HTH,

STeVe



More information about the Python-list mailing list