Alternating Lists

February 1, 2019

Today’s exercise is a simple task in list manipulation:

Write a program that takes one or more lists and returns a single list containing the elements of the input lists, taken alternately from the lists. If the lists are of different lengths, continue taking items from the lists that remain.

For instance, given the inputs (1 2 3 4 5), (a b c) and (w x y z), the desired output is (1 a w 2 b x 3 c y 4 z 5).

Your task is to write a program to take items alternately from multiple lists. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.


Pages: 1 2