Aaron
> You're looking for the built-in `zip` function.
I like both answers! But in case you want to do other computations on
the list during the zip:
array3 = [s for s in zip(array1, array2)]
However, careful reading of the python docs leads me to believe that you
will wind up with a list of tuples, so maybe you need something
else....maybe it's not possible with list comprehension, because you'd
need to split the zipped array afterwards. Of course, the first
suggestion works best, but it doesn't strike me as particularly pythonic
(indexes in list comprehension? what is this, javascript?).
OK, got it. I don't think it's possible without using a for loop, so it
will be slower than the one with indexes, but just as an exercise in
pythonicity:
array3 = []
for a in zip(array1, array2):
array3.extend(a)
# here, array3 should contain [array1[0], array2[0], array1[1], ....
array2[n]].
Sorry I chatted you up and wound up with a slow solution :) then again,
the python documentation on list comprehensions uses an index, too, so I
guess you'd be OK with it!
--
Mark Holmquist
Student, Computer Science
University of Redlands
MarkT...@gmail.com